﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.IO.Ports;
using System.Text.RegularExpressions;
using System.Threading;
using System.Reflection; // 引用这个才能使用Missing字段
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Xml;
using System.Web;
using System.Runtime.InteropServices;

using System.IO;
using System.Net;
using System.Collections;
using System.Xml.Serialization;
using Newtonsoft.Json;
using LitJson;
using Newtonsoft.Json.Linq;

namespace weiqijiance
{
    public partial class TESTSDS : Form
    {
        public mainform m_mainform;
        /// <summary>
        /// 结果变量
        /// </summary>
        public int iHCG;
        public float fCOG;
        public float fLAMDAG;

        public int iHCD;
        public float fCOD;

        public float fwendu;
        public float fshidu;
        public float fdaqiya;



        public float fCO2H;//高怠速工况CO2检测结果（单位：% vol）
        public int fRevH;//高怠速工况发动机转速
        public float fCO2;//	怠速工况CO2检测结果（单位：% vol）
        public int fRev;//	怠速工况发动机转速
        /// <summary>
        ///限值变量
        /// </summary>
        public int iHCXZG;
        public float fCOXZG;

        public int iHCXZD;
        public float fCOXZD;

        public string sxianshineirong;
        public int itime;//剩余时间
        public int itrun;//当前发动机转速
        public int iHC;//当前HC值
        public float fCO;//当前CO值
        public float fCOCO2;
        public float fO2;//当前O2值
        public float fyw;//当前油温fwj

        public string szsqz;
        public string ssdszs;
        //public string ssdszsyq;
        public string ssfyqyw;//是否要求油温检测
        public string sASMllgd;
        public bool SDS_Start;
        public bool SDS_Stop;//终止检测

        public int dsfdjzs=0;
        public int gdsfdjzs = 0;
        public float jyyw=0f;

        public Thread t1;
        public Thread t2;
        public Thread t3;

        public string shphm;
        public string shpzl;


        // /声明INI文件的写操作函数 WritePrivateProfileString()
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

        //声明INI文件的读操作函数 GetPrivateProfileString()
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
        private string sPath = null;

        public int DETECT_ID = 0;
        public static string businessId;
        public static string registCode;
        public static string timeStart;
        public static string timeEnd;
        public int edzs;
        public string scllx;


        public string[] scolorname;
        public TextBox[] m_tex;

        public string[] sBJname;
        public string[] sBJnamecolor;
        public bool bdushu;

        public string szhuansu;//修正转速

        //过程数据NO

        public int[] m_NOGCSJYR = new int[30];
        public int[] m_NOGCSJG15 = new int[30];
        public int[] m_NOGCSJG = new int[30];
        public float[] m_NOGCSJD15 = new float[30];
        public float[] m_NOGCSJD = new float[30];
        //25过程数据
        int[] m_HCGCSJYR = new int[30];
        float[] m_COGCSJYR = new float[30];
        float[] m_O2GCSJYR = new float[30];
        float[] m_CO2GCSJYR = new float[30];
        float[] m_LAMDAGCSJYR = new float[30];
        int[] m_TrunGCSJYR = new int[30];
        string[] m_ProcessTimeYR = new string[30];
        float[] m_YWGCSJYR = new float[30];

        float[] syouwenYR = new float[30];		//测试工况流量计温度每秒数据,单位：℃
        float[] swenduYR = new float[30];		//测试工况环境温度每秒数
        float[] sdaqiyiYR = new float[30];		//测试工况环境大气压力每秒数据,单位：kPa
        float[] sshiduYR = new float[30];


        int[] m_HCGCSJG15 = new int[15];
        float[] m_COGCSJG15 = new float[15];
        float[] m_O2GCSJG15 = new float[15];
        float[] m_CO2GCSJG15 = new float[15];
        float[] m_LAMDAGCSJG15 = new float[15];
        int[] m_TrunGCSJG15 = new int[15];
        string[] m_ProcessTimeG15 = new string[15];
        float[] m_YWGCSJG15 = new float[15];

        float[] syouwenG15 = new float[15];		//测试工况流量计温度每秒数据,单位：℃
        float[] swenduG15 = new float[15];		//测试工况环境温度每秒数
        float[] sdaqiyiG15 = new float[15];		//测试工况环境大气压力每秒数据,单位：kPa
        float[] sshiduG15 = new float[15];



        int[] m_HCGCSJG = new int[30];
        float[] m_COGCSJG = new float[30];
        float[] m_O2GCSJG = new float[30];
        float[] m_CO2GCSJG = new float[30];
        float[] m_LAMDAGCSJG = new float[30];
        int[] m_TrunGCSJG = new int[30];
        string[] m_ProcessTimeG = new string[30];
        float[] m_YWGCSJG = new float[30];

        float[] syouwenG = new float[30];		//测试工况流量计温度每秒数据,单位：℃
        float[] swenduG = new float[30];		//测试工况环境温度每秒数
        float[] sdaqiyiG = new float[30];		//测试工况环境大气压力每秒数据,单位：kPa
        float[] sshiduG = new float[30];




        int[] m_HCGCSJD15 = new int[15];
        float[] m_COGCSJD15 = new float[15];
        float[] m_O2GCSJD15 = new float[15];
        float[] m_CO2GCSJD15 = new float[15];
        float[] m_LAMDAGCSJD15 = new float[15];
        int[] m_TrunGCSJD15 = new int[15];
        string[] m_ProcessTimeD15 = new string[15];
        float[] m_YWGCSJD15 = new float[15];
        float[] syouwenD15 = new float[15];		//测试工况流量计温度每秒数据,单位：℃
        float[] swenduD15 = new float[15];		//测试工况环境温度每秒数
        float[] sdaqiyiD15 = new float[15];		//测试工况环境大气压力每秒数据,单位：kPa
        float[] sshiduD15 = new float[15];



        int[] m_HCGCSJD = new int[30];
        float[] m_COGCSJD = new float[30];

        float[] m_O2GCSJD = new float[30];
        float[] m_CO2GCSJD = new float[30];
        float[] m_LAMDAGCSJD = new float[30];
        int[] m_TrunGCSJD = new int[30];
        string[] m_ProcessTimeD = new string[30];
        float[] m_YWGCSJD = new float[30];


        float[] syouwenD = new float[30];		//测试工况流量计温度每秒数据,单位：℃
        float[] swenduD = new float[30];		//测试工况环境温度每秒数
        float[] sdaqiyiD = new float[30];		//测试工况环境大气压力每秒数据,单位：kPa
        float[] sshiduD = new float[30];



        float[] m_wendu = new float[300];
        float[] m_shidu = new float[300];
        float[] m_daqiya = new float[300];


        string[] OBD_jqmkd = new string[1000];
        string[] OBD_fh = new string[1000];
        string[] OBD_qycgqxh = new string[1000];
        string[] OBD_glkqxs = new string[1000];
        string[] OBD_ymkd = new string[1000];
        string[] OBD_cs = new string[1000];
        string[] OBD_fdjzs = new string[1000];
        string[] OBD_jql = new string[1000];
        string[] OBD_jqyl = new string[1000];
        string[] OBD_scgl = new string[1000];
        string[] OBD_zyyl = new string[1000];
        string[] OBD_hyl = new string[1000];
        string[] OBD_no = new string[1000];
        string[] OBD_nsbsl = new string[1000];
        string[] OBD_pqwd = new string[1000];
        string[] OBD_klbjqyc = new string[1000];
        string[] OBD_egrkd = new string[1000];
        string[] OBD_rypsyl = new string[1000];

        string[] OBD_sjxl = new string[1000];
        public int iobd;
        public int itlsj;
        public DateTime dtl;


        public TESTSDS(string sbusinessId, string sregistCode)
        {
            InitializeComponent();
            readjcxx();
            szhuansu = "";
            SDS_Start = false;
            businessId = sbusinessId;
            registCode = sregistCode;
            dtl = DateTime.Now;
            bianliangchushihua();
            sxianshineirong = "双怠速检测";
            readshezhiJC();
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            x = this.Width;
            y = this.Height;
            setTag(this);


            scolorname = new string[16] {"提示框",
                                    "号牌号码",
                                    "转速",
                                    "提示时间",
                                    "当前HC",
                                    "当前CO",
                                    "油温",
                                    "温度",
                                    "湿度",
                                    "大气压",
                                    "高怠速HC",
                                    "高怠速CO",
                                    "高怠速LAMDA",
                                    "怠速HC",
                                    "怠速CO",
                                    "当前CO+CO2"
                                    };//"提示信息"
            m_tex = new TextBox[16] {
                                    xinxixianshi,
                                    hphm,
                                    trun,
                                    time,
                                    HC,
                                    CO,
                                    YOUWEN,
                                    wendu,
                                    shidu,
                                    daqiya,
                                    HCG,
                                    COG,
                                    LAMDAG,
                                    HCD,
                                    COD,
                                    COCO2};

            sBJname = new string[17] { "窗体背景",
                                        "提示框",
                                        "号牌号码",
                                        "转速",
                                        "提示时间",
                                        "当前HC",
                                        "当前CO",
                                        "油温",
                                        "温度",
                                        "湿度",
                                        "大气压",
                                        "高怠速HC",
                                        "高怠速CO",
                                        "高怠速LAMDA",
                                        "怠速HC",
                                        "怠速CO",
                                        "当前CO+CO2"};

            sBJnamecolor = new string[17] {
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC",
                                        "#AABBCC" };

           
           
            showTextBoxCOLOR();
            readshezhiBJ();
            timer1.Enabled = true;
            xinxixianshi.Text = string.Format("仪器调零中...");
            skinBut_ksjc.Enabled = false;
           
        }
        //int iedzs = 0;
        public void bianliangchushihua()
        {
            iHCG = 0;
            fCOG = 0;
            iHCD = 0;
            fCOD = 0;
            fLAMDAG = 0;

            iHCXZG = 0;
            fCOXZG = 0;
            iHCXZD = 0;
            fCOXZD = 0;

            //this.BackColor = Color.Black;

            this.xinxixianshi.ForeColor = Color.Green;
            this.hphm.ForeColor = Color.Green;
            this.time.ForeColor = Color.Green;
            this.trun.ForeColor = Color.Green;
            this.HC.ForeColor = Color.Green;
            this.CO.ForeColor = Color.Green;
            this.YOUWEN.ForeColor = Color.Green;
            this.wendu.ForeColor = Color.Green;
            this.daqiya.ForeColor = Color.Green;
            this.shidu.ForeColor = Color.Green;
            this.HCG.ForeColor = Color.Green;
            this.COG.ForeColor = Color.Green;
            this.LAMDAG.ForeColor = Color.Green;
            this.HCD.ForeColor = Color.Green;
            this.COD.ForeColor = Color.Green;
            this.COCO2.ForeColor = Color.Green;


            this.xinxixianshi.Text = "-";
            this.hphm.Text = "-";
            this.time.Text = "-";
            this.trun.Text = "-";
            this.HC.Text = "-";
            this.CO.Text = "-";
            this.YOUWEN.Text = "-";
            this.wendu.Text = "-";
            this.daqiya.Text = "-";
            this.shidu.Text = "-";
            this.HCG.Text = "-";
            this.COG.Text = "-";
            this.LAMDAG.Text = "-";
            this.HCD.Text = "-";
            this.COD.Text = "-";
            this.COCO2.Text = "-";

            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\车辆信息.ini";
            string path1 = string.Format(@"{0}", path);
            Ini(path1);


            hphm.Text = ReadValue("设置", "车牌号码");

            scllx = ReadValue("设置", "车辆类型");
            shpzl = ReadValue("设置", "号牌种类");
            int.TryParse(ReadValue("设置", "额定转速"), out edzs);

            shphm = hphm.Text.Trim();
            mainform.hphm = ReadValue("设置", "车牌号码");
            mainform.hpzl = ReadValue("设置", "号牌种类");


        }
        public void readshezhiJC()
        {
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\检测要求设置.ini";
            string path1 = string.Format(@"{0}", path);
            Ini(path1);

            //szsqz = ReadValue("设置", "汽油车转速取值");
            {
                //ssdszs = "是";//ReadValue("设置", "双怠速要求转速");
                //ssfyqyw = ReadValue("设置", "油温检测要求");
                //sASMllgd = "是";// ReadValue("设置", "ASM流量过低要求");
                ssdszs = "否";//ReadValue("设置", "双怠速要求转速");
                sASMllgd = "否";// ReadValue("设置", "ASM流量过低要求");
            }//tese

            //ssdszsyq = ReadValue("设置", "双怠速要求转速初始");
        }
        public void readjcxx()
        {
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\检测参数设置.ini";
            string path1 = string.Format(@"{0}", path);
            Ini(path1);
            int.TryParse(ReadValue("设置", "ASM调零时间/秒"), out itlsj);
            if (itlsj < 10)
            {
                itlsj = 35;
            }
        }
        public void showTextBoxCOLOR()
        {
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\双怠速工况字体颜色配置.ini";
            string path1 = string.Format(@"{0}", path);
            Ini(path1);

            for (int i = 0; i < 16; i++)
            {
                textbox_xs(m_tex[i], System.Drawing.ColorTranslator.FromHtml(ReadValue("双怠速工况字体颜色配置", scolorname[i])));
            }
            Color tishiziti = System.Drawing.ColorTranslator.FromHtml(ReadValue("双怠速工况字体颜色配置", "提示框"));
            label1.ForeColor = tishiziti;
            label1.ForeColor = tishiziti;
            label2.ForeColor = tishiziti;
            label3.ForeColor = tishiziti;
            label4.ForeColor = tishiziti;
            label5.ForeColor = tishiziti;
            label6.ForeColor = tishiziti;
            label7.ForeColor = tishiziti;
            label8.ForeColor = tishiziti;
            label9.ForeColor = tishiziti;
            label10.ForeColor = tishiziti;
            label11.ForeColor = tishiziti;
            label12.ForeColor = tishiziti;
            label13.ForeColor = tishiziti;
            label14.ForeColor = tishiziti;
            label15.ForeColor = tishiziti;
            label16.ForeColor = tishiziti;
            label17.ForeColor = tishiziti;
            label19.ForeColor = tishiziti;
        }
        public void textbox_xs(TextBox tex, Color cColor)//textbox显示风格
        {
            tex.ForeColor = cColor;
        }
        public void readshezhiBJ()
        {
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\双怠速工况背景颜色配置.ini";
            string path1 = string.Format(@"{0}", path);
            Ini(path1);

            for (int i = 0; i < 17; i++)
            {
                sBJnamecolor[i] = ReadValue("双怠速工况背景颜色配置", sBJname[i]);

                if (i > 0)
                {
                    textbox_BJ(m_tex[i-1], System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]));
                }
                else
                {
                    groupBox1.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    groupBox2.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    groupBox3.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    groupBox4.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    groupBox5.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    groupBox6.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    groupBox7.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    label19.BackColor = System.Drawing.ColorTranslator.FromHtml(sBJnamecolor[i]);
                    
                    
                   
                }
            }

        }
        public void textbox_BJ(TextBox tex, Color cColor)//textbox显示风格
        {

            tex.BackColor = cColor;

        }
        
          public void buttton_pic(Button but, string sfile)//按钮控件显示风格
        {
            but.BackgroundImage = Image.FromFile(string.Format(@"{0}", sfile));
            but.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
            but.ImageAlign = ContentAlignment.TopLeft;
            but.TextAlign = ContentAlignment.TopRight;
            but.ForeColor = Color.Red;
            but.Font = new System.Drawing.Font("黑体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); ;

        }


          #region 控件大小随窗体大小等比例缩放
          private float x;//定义当前窗体的宽度
          private float y;//定义当前窗体的高度
          private void setTag(Control cons)
          {
              foreach (Control con in cons.Controls)
              {
                  con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
                  if (con.Controls.Count > 0)
                  {
                      setTag(con);
                  }
              }
          }
          private void setControls(float newx, float newy, Control cons)
          {
              //遍历窗体中的控件，重新设置控件的值
              foreach (Control con in cons.Controls)
              {
                  //获取控件的Tag属性值，并分割后存储字符串数组
                  if (con.Tag != null)
                  {
                      string[] mytag = con.Tag.ToString().Split(new char[] { ';' });
                      //根据窗体缩放的比例确定控件的值
                      con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度
                      con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度
                      con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距
                      con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距
                      Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小
                      con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
                      if (con.Controls.Count > 0)
                      {
                          setControls(newx, newy, con);
                      }
                  }
              }
          }
          #endregion
          
        //ini文件
        public void Ini(string path)
        {
            this.sPath = path;
        }
        public void Writue(string section, string key, string value)
        {
            // section=配置节，key=键名，value=键值，path=路径
            WritePrivateProfileString(section, key, value, sPath);
        }
        public string ReadValue(string section, string key)
        {
            // 每次从ini中读取多少字节
            System.Text.StringBuilder temp = new System.Text.StringBuilder(255);

            // section=配置节，key=键名，temp=上面，path=路径
            GetPrivateProfileString(section, key, "", temp, 255, sPath);
            return temp.ToString();
        }
        //ini文件

        private void xianshixinxi()
        {
            if (this.xinxixianshi.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshixinxi);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
               
                this.xinxixianshi.Text = string.Format(@"{0}", sxianshineirong);
            }
        }
        private void xianshitime()
        {
            if (this.time.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitime);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                if (itime == 0)
                {
                    this.time.Text = string.Format(@"-");
                }
                else
                {
                    this.time.Text = string.Format(@"{0}", itime);
                }
               
            }
        }
        private void xianshitrun()
        {
            if (this.trun.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitrun);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                if (itrun == 0)
                {
                    this.trun.Text = string.Format(@"-");
                }
                else
                {
                    this.trun.Text = string.Format(@"{0}", itrun);
                }
               
            }
        }
        private void xianshiYOUWEN()
        {
            if (this.YOUWEN.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiYOUWEN);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                if ((byw ? fywrg : m_mainform.objfqy.m_fyw) == 0)
                {
                    this.YOUWEN.Text = string.Format(@"-");
                }
                else
                {
                    this.YOUWEN.Text = string.Format(@"{0}",fyw);//油温

                }

            }
        }
        private void xianshiHC()
        {
            if (this.HC.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiHC);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.HC.Text = string.Format(@"{0}", iHC);
            }
        }
        private void xianshiCO()
        {
            if (this.CO.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiCO);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.CO.Text = string.Format(@"{0}", fCO.ToString("0.00"));
            }
        }
        private void xianshiCOCO2()
        {
            if (this.COCO2.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiCOCO2);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.COCO2.Text = string.Format(@"{0}", fCOCO2.ToString("0.00"));
            }
        }
        private void xianshiHCG()
        {
            if (this.HCG.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiHCG);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.HCG.Text = string.Format(@"{0}", iHCG);
            }
        }
        private void xianshiCOG()
        {
            if (this.COG.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiCOG);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.COG.Text = string.Format(@"{0}", fCOG.ToString("0.00"));
            }
        }
        private void xianshiLAMDAG()
        {
            if (this.LAMDAG.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiLAMDAG);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.LAMDAG.Text = string.Format(@"{0}", fLAMDAG.ToString("0.000"));
            }
        }
        private void xianshiHCD()
        {
            if (this.HCD.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiHCD);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.HCD.Text = string.Format(@"{0}", iHCD);
            }
        }
        private void xianshiCOD()
        {
            if (this.COD.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiCOD);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.COD.Text = string.Format(@"{0}", fCOD.ToString("0.00"));
            }
        }
        private void xianshiWENDU()
        {
            if (this.wendu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiWENDU);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.wendu.Text = string.Format(@"{0}", fwendu);
            }
        }
        private void xianshiSHIDU()
        {
            if (this.shidu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiSHIDU);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.shidu.Text = string.Format(@"{0}", fshidu);
            }
        }
        private void xianshiDAQIYA()
        {
            if (this.daqiya.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiDAQIYA);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.daqiya.Text = string.Format(@"{0}", fdaqiya);
            }
        }

        protected void thisclose()
        {
            
            this.Invoke(new Action(this.Close));  //使用委托关闭该窗体
        }

        private delegate void FlushClient();//代理

        public void Thread1()
        {
            StratTest();          
        }


        public void Thread2()
        {

            DateTime ddatagcsj = DateTime.Now;
            while (bdushu)
            {
                if (m_mainform.DateDiff(DateTime.Now, ddatagcsj) > 500)
                {
                    //if (m_mainform.sfqycj.Contains("鸣泉50A"))
                    //{
                    //    m_mainform.SendDeviceCmdGas(0x60, 0x9B);//  发送读取命令  
                    //}
                    //else
                    //{
                    //    m_mainform.SendDeviceCmdGas(0xA3, 0x58);//  发送读取命令 //WWT
                    //}
                    m_mainform.objfqy.SendDeviceCmd(3);
                    ddatagcsj = DateTime.Now;

                }
                Thread.Sleep(200);
                ///
            }

        }
        string lamda;
        bool bgood;
        int ilandapd;
        public void StratTest()
        {
            bfh = false;
            DETECT_ID = 0;
            if (m_mainform.IsInt(businessId))
            {
                int.TryParse(businessId, out DETECT_ID);
            }
            m_mainform.objbass.SendMessage("03", "开始检测");
            m_mainform.objbass.XXTZ("03");//中科开始
            m_ProcessTimeD[0] = "";
            bgood = true;
            ilandapd = 1;
            lamda = "0";
            //判断额定转速
            iobd = 0;
            //edzs = 2500;
            //if (scllx.Contains("重"))
            //{
            //    edzs = 1800;
            //}
            gdsfdjzs = edzs;

            DateTime dcomfh = DateTime.Now;
            //录像开始
          //  try
            {
                int inspectNum = 1;
                SDS_Start = true;
                SDS_Stop = false;
                timeStart = DateTime.Now.ToLocalTime().ToString();



                sxianshineirong = "双怠速检测";
                xianshixinxi();
                {
                    string sshanghang = string.Format("双怠速检测");
                    string sxiahang = string.Format("");
                    m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                }
                //m_mainform.SendDeviceCmdGas(0x79, 0x82);
                for (int iqd = 0; iqd < 3; iqd++)
                {
                    m_mainform.objfqy.SendDeviceCmd(1);//启动废气仪
                    Thread.Sleep(1000);
                }
                if (m_mainform.objfqy.m_fWenDu > 22)
                {
                    sxianshineirong = string.Format("请启动冷却风机");
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("请启动冷却风机");
                        string sxiahang = string.Format("");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    Thread.Sleep(2000);
                }
                Thread.Sleep(2500);
                bdushu = true;
                t2.Start();
                //t3.Start();

                //油温检测开始
                //if (ssfyqyw.Contains("是"))
                {

                    while (true)
                    {

                        Thread.Sleep(500);
                        sxianshineirong = string.Format("当前油温:{0}度不符合测试要求", (byw ? fywrg : m_mainform.objfqy.m_fyw));
                        xianshixinxi();
                        {
                            string sshanghang = string.Format("当前油温{0}度", (byw ? fywrg : m_mainform.objfqy.m_fyw));
                            string sxiahang = string.Format("不符合测试要求");
                            m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                        }

                        if ((byw ? fywrg : m_mainform.objfqy.m_fyw) > 80)
                        {
                            break;
                        }
                    }
                }

                jyyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);

                //

                while (true)//test
                {
                    Thread.Sleep(500);
                    sxianshineirong = string.Format("CO2+CO大于6 {0}", m_mainform.objfqy.m_fCo2 + m_mainform.objfqy.m_fCo);
                    xianshixinxi();

                    {
                        string sshanghang = string.Format("CO2+CO大于6");
                        string sxiahang = string.Format("{0}",m_mainform.objfqy.m_fCo2 + m_mainform.objfqy.m_fCo);
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    if (bydhh)
                        break;

                    if (m_mainform.objfqy.m_fCo2 + m_mainform.objfqy.m_fCo > 6)
                    {
                        break;
                    }
                }

                sxianshineirong = "预热开始";
                xianshixinxi();
                {
                    string sshanghang = string.Format("预热开始");
                    string sxiahang = string.Format("");
                    m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                }
                Thread.Sleep(1500);
                DateTime dtgcsj = DateTime.Now;
                int igcsjcount = 1;
                bsenddate = true;
                //3500预热30时间
                for (int k = 30; k > 0; k--)//取数平稳//15
                {

                    sxianshineirong = "预热在" + (edzs * 0.6).ToString("0") + "转以上";
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("预热在" + (edzs * 0.6).ToString("0") + "转以上");
                        string sxiahang = string.Format("当前{0}剩{1}", itrun,k);
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    DateTime dstart = DateTime.Now;

                    if (!m_mainform.getOBD_GCSJ(businessId))//读取OBD过程数据
                    {
                        sxianshineirong = "找不到OBD过程数据，请接好OBD再上线！";
                        xianshixinxi();
                        {
                            string sshanghang = string.Format("找不到OBD");
                            string sxiahang = string.Format("请接好OBD再上线");
                            m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                        }
                        return;
                    }
                    bool bfs = false;
                    while (true)
                    {


                        //m_mainform.gethuanjing();//读取数据库环境参数 

                        //fwendu = m_mainform.objfqy.m_fWenDu;
                        //fshidu = m_mainform.objfqy.m_fShiDu;
                        //fdaqiya = m_mainform.objfqy.m_fYaLi;

                        fwendu = m_mainform.objfqy.m_fWenDu;
                        fshidu = m_mainform.objfqy.m_fShiDu;
                        fdaqiya = m_mainform.objfqy.m_fYaLi;

                        fyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);//fwj
                        xianshiYOUWEN();
                        xianshiWENDU();
                        xianshiSHIDU();
                        xianshiDAQIYA();


                        iHC = m_mainform.objfqy.m_iHc;
                        fCO = m_mainform.objfqy.m_fCo;
                        fCOCO2 = m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2;
                        xianshiHC();
                        xianshiCO();
                        xianshiCOCO2();



                        iobd = 30 - k;
                        OBD_jqmkd[iobd] = m_mainform.OBD_jqmkd;
                        OBD_fh[iobd] = m_mainform.OBD_fh;
                        OBD_qycgqxh[iobd] = m_mainform.OBD_qycgqxh;
                        OBD_glkqxs[iobd] = m_mainform.OBD_glkqxs;
                        OBD_ymkd[iobd] = m_mainform.OBD_ymkd;
                        OBD_cs[iobd] = m_mainform.OBD_cs;
                        OBD_fdjzs[iobd] = m_mainform.OBD_fdjzs;
                        OBD_jql[iobd] = m_mainform.OBD_jql;
                        OBD_jqyl[iobd] = m_mainform.OBD_jqyl;
                        OBD_scgl[iobd] = m_mainform.OBD_scgl;
                        OBD_zyyl[iobd] = m_mainform.OBD_zyyl;
                        OBD_hyl[iobd] = m_mainform.OBD_hyl;
                        OBD_no[iobd] = m_mainform.OBD_no;
                        OBD_nsbsl[iobd] = m_mainform.OBD_nsbsl;
                        OBD_pqwd[iobd] = m_mainform.OBD_pqwd;
                        OBD_klbjqyc[iobd] = m_mainform.OBD_klbjqyc;
                        OBD_egrkd[iobd] = m_mainform.OBD_egrkd;
                        OBD_rypsyl[iobd] = m_mainform.OBD_rypsyl;
                        OBD_sjxl[iobd] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");





                        //if (szsqz.Contains("废气仪"))
                        //{
                        //    itrun = m_mainform.m_iGasturn;
                        //}
                        //else
                        //{
                        //    itrun = m_mainform.objbtg.m_iTurn;
                        //}
                        if (rbOBDZS.Checked)
                        {
                            int ifdjzs = 0;
                            int.TryParse(m_mainform.OBD_fdjzs, out ifdjzs);
                            itrun = ifdjzs;
                        }
                        else
                        {
                            itrun = m_mainform.objzsy.m_iGasturn;
                        }
                        xianshitrun();
                        xianshiYOUWEN();
                        //废气转速
                        m_HCGCSJYR[30 - k] = m_mainform.objfqy.m_iHc;
                        m_COGCSJYR[30 - k] = m_mainform.objfqy.m_fCo;
                        m_O2GCSJYR[30 - k] = m_mainform.objfqy.m_fO2;
                        m_CO2GCSJYR[30 - k] = m_mainform.objfqy.m_fCo2;
                        m_LAMDAGCSJYR[30 - k] = m_mainform.objfqy.m_fLamda;
                        m_TrunGCSJYR[30 - k] = itrun;
                        m_ProcessTimeYR[30 - k] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        m_YWGCSJYR[30 - k] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                        m_NOGCSJYR[30 - k] = m_mainform.objfqy.m_iNo;

                        m_wendu[30 - k] = m_mainform.objfqy.m_fWenDu;
                        m_shidu[30 - k] = m_mainform.objfqy.m_fShiDu;
                        m_daqiya[30 - k] = m_mainform.objfqy.m_fYaLi;

                        //if (ssdszs.Contains("是"))
                        {
                            if ((itrun < (edzs * 0.6)))// || itrun > 3500 + 500))// && (itrun > 500))test
                            {
                                k = 30;
                                trun.ForeColor = Color.Red;
                            }
                            else
                            {
                                trun.ForeColor = Color.Green;
                            }
                        }
                        //else 
                        //{
                        //    if (itrun < 500 && ssdszsyq != "否")
                        //    {
                        //        k = 30;
                        //        trun.ForeColor = Color.Red;
                        //    }
                        //    else if ((itrun < 3500 - 200 || itrun > 3500 + 200) && (itrun > 500))
                        //    {
                        //        itrun = 3400 + m_mainform.getRandom(1, 9) * 10;// +m_mainform.getRandom(0, 9);
                        //    }

                        //}
                        //model.SDS.SDSgcsjZM objsdszm = new model.SDS.SDSgcsjZM();
                        objsdszm.businessId = businessId;       //受理编码
                        objsdszm.lineCode = m_mainform.lineCode;            //检测站编码
                        objsdszm.jcgcdysj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //检测过程数据对应时间
                        //objsdszm.imslsh = 30 - k + 1;              //秒数流水号
                        objsdszm.itrun = itrun;        //逐秒发动机转速
                        objsdszm.m_iHc = m_mainform.objfqy.m_iHc;                 //逐秒HC浓度值(未经修正)
                        objsdszm.m_fCo = m_mainform.objfqy.m_fCo;                 //逐秒CO浓度值(未经修正)
                        objsdszm.m_fCo2 = m_mainform.objfqy.m_fCo2;               //逐秒CO2浓度值
                        objsdszm.m_iNo = m_mainform.objfqy.m_iNo;                 //
                        objsdszm.m_fO2 = m_mainform.objfqy.m_fO2;                 //逐秒O2浓度值
                        objsdszm.m_fLamda = m_mainform.objfqy.m_fLamda;          //逐秒计算的λ值
                        objsdszm.m_fWenDu = m_mainform.objfqy.m_fWenDu;     //测试工况环境温度每秒数据
                        objsdszm.m_fYaLi = m_mainform.objfqy.m_fYaLi;      //测试工况环境大气压力每秒数据
                        objsdszm.m_fShiDu = m_mainform.objfqy.m_fShiDu;        //测试工况环境相对湿度每秒数据
                        objsdszm.m_fyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);            //逐秒发动机机油温度
                        objsdszm.GKLX = "0";                     //工况过程类型
                        //objsdszm.ProcessTime = dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss");
                        //m_mainform.objbass.zmgcsjsds(businessId, objsdszm);
                        //if (m_mainform.sfOBD)
                        //{
                        //    m_mainform.objbass.sendOBDGCSJ(businessId, dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss"), objsdszm.imslsh);
                        //}
                        //igcsjcount++;


                        ////云景过程数据
                        //if (m_mainform.sconnetname.Contains("云景"))
                        //{
                        //    JsonData value = new LitJson.JsonData();
                        //    value["InspectionNum"] = businessId;
                        //    value["SceneCode"] = m_mainform.lineCode;
                        //    value["ProcessTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        //    value["Second_NO"] = 30 - k + 1;
                        //    value["Flow_RotateSpeed"] = itrun;
                        //    value["Flow_HC"] = m_mainform.objfqy.m_iHc;
                        //    value["Flow_CO"] = m_mainform.objfqy.m_fCo;
                        //    value["Flow_CO2"] = m_mainform.objfqy.m_fCo2;
                        //    value["Flow_NO"] = m_mainform.objfqy.m_iNo;
                        //    value["Flow_O2"] = m_mainform.objfqy.m_fO2;
                        //    value["Flow_Lambda"] = m_mainform.objfqy.m_fLamda;
                        //    value["EnvirTemperature"] = m_mainform.objfqy.m_fWenDu;
                        //    value["EnvirAirPressure"] = m_mainform.objfqy.m_fYaLi;
                        //    value["EnvirHumidity"] = m_mainform.objfqy.m_fShiDu;
                        //    value["EngineOilTemperature"] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                        //    value["GKLX"] = "0";

                        //    string svalue = value.ToJson();
                        //    sendSDSGCSJ(businessId, svalue);
                        //}
                        //

                        itime = k;
                        xianshitime();
                        if (!bfs)
                        {
                            if (setlwgcsj())
                            {
                                bfs = true;
                            }
                        }
                        //剩余时间
                        Thread.Sleep(200);
                        if (m_mainform.DateDiff(DateTime.Now, dstart) >800)
                            break;

                    }
                    if (SDS_Stop)
                    {
                        m_mainform.flowwq.LedWrite("终止检测", "", 1);
                        sxianshineirong = string.Format(@"终止检测");
                        xianshixinxi();
                        return;
                    }
                }
                sxianshineirong = "插入采样管";
                xianshixinxi();
                {
                    string sshanghang = string.Format("插入采样管");
                    string sxiahang = string.Format("");
                    m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                }

                Thread.Sleep(2500);
                sxianshineirong = "高怠速降到" + (edzs * 0.5).ToString("0") + "转";
                xianshixinxi();
                {
                    string sshanghang = string.Format("高怠速");
                    string sxiahang = string.Format("降到" + (edzs * 0.5).ToString("0") + "转");
                    m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                }

                for (int k = 15; k > 0; k--)//取数平稳//15
                {

                    {
                        string sshanghang = string.Format((edzs * 0.5).ToString("0") + "转稳定时间");
                        string sxiahang = string.Format("当前{0}剩{1}",itrun,k);
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    DateTime dstart = DateTime.Now;

                    if (!m_mainform.getOBD_GCSJ(businessId))//读取OBD过程数据
                    {
                        sxianshineirong = "找不到OBD过程数据，请接好OBD再上线！";
                        xianshixinxi();
                        {
                            string sshanghang = string.Format("找不到OBD");
                            string sxiahang = string.Format("请接好OBD");
                            m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                        }
                        return;
                    }
                    bool bfs = false;
                    while (true)
                    {

                        //if (szsqz.Contains("废气仪"))
                        //{
                        //    itrun = m_mainform.m_iGasturn;
                        //}
                        //else
                        //{
                        //    itrun = m_mainform.m_iTurn;
                        //}
                        if (rbOBDZS.Checked)
                        {
                            int ifdjzs = 0;
                            int.TryParse(m_mainform.OBD_fdjzs, out ifdjzs);
                            itrun = ifdjzs;
                        }
                        else
                        {
                            itrun = m_mainform.objzsy.m_iGasturn;
                        }
                        itime = k;
                        xianshitrun();
                        xianshiYOUWEN();
                        xianshitime();

                        iHC = m_mainform.objfqy.m_iHc;
                        fCO = m_mainform.objfqy.m_fCo;
                        fCOCO2 = m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2;
                        xianshiHC();
                        xianshiCO();
                        xianshiCOCO2();


                        m_HCGCSJG15[15 - k] = m_mainform.objfqy.m_iHc;
                        m_COGCSJG15[15 - k] = m_mainform.objfqy.m_fCo;
                        m_O2GCSJG15[15 - k] = m_mainform.objfqy.m_fO2;
                        m_CO2GCSJG15[15 - k] = m_mainform.objfqy.m_fCo2;
                        m_LAMDAGCSJG15[15 - k] = m_mainform.objfqy.m_fLamda;
                        m_TrunGCSJG15[15 - k] = itrun;
                        m_ProcessTimeG15[15 - k] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        //m_mainform.gethuanjing();
                        m_YWGCSJG15[15 - k] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                        m_NOGCSJG15[15 - k] = m_mainform.objfqy.m_iNo;

                        m_wendu[30 + 15 - k] = m_mainform.objfqy.m_fWenDu;
                        m_shidu[30 + 15 - k] = m_mainform.objfqy.m_fShiDu;
                        m_daqiya[30 + 15 - k] = m_mainform.objfqy.m_fYaLi;


                        iobd = 30 + 15 - k;
                        OBD_jqmkd[iobd] = m_mainform.OBD_jqmkd;
                        OBD_fh[iobd] = m_mainform.OBD_fh;
                        OBD_qycgqxh[iobd] = m_mainform.OBD_qycgqxh;
                        OBD_glkqxs[iobd] = m_mainform.OBD_glkqxs;
                        OBD_ymkd[iobd] = m_mainform.OBD_ymkd;
                        OBD_cs[iobd] = m_mainform.OBD_cs;
                        OBD_fdjzs[iobd] = m_mainform.OBD_fdjzs;
                        OBD_jql[iobd] = m_mainform.OBD_jql;
                        OBD_jqyl[iobd] = m_mainform.OBD_jqyl;
                        OBD_scgl[iobd] = m_mainform.OBD_scgl;
                        OBD_zyyl[iobd] = m_mainform.OBD_zyyl;
                        OBD_hyl[iobd] = m_mainform.OBD_hyl;
                        OBD_no[iobd] = m_mainform.OBD_no;
                        OBD_nsbsl[iobd] = m_mainform.OBD_nsbsl;
                        OBD_pqwd[iobd] = m_mainform.OBD_pqwd;
                        OBD_klbjqyc[iobd] = m_mainform.OBD_klbjqyc;
                        OBD_egrkd[iobd] = m_mainform.OBD_egrkd;
                        OBD_rypsyl[iobd] = m_mainform.OBD_rypsyl;
                        OBD_sjxl[iobd] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");


                        //model.SDS.SDSgcsjZM objsdszm = new model.SDS.SDSgcsjZM();
                        objsdszm.businessId = businessId;       //受理编码
                        objsdszm.lineCode = m_mainform.lineCode;            //检测站编码
                        objsdszm.jcgcdysj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //检测过程数据对应时间
                        //objsdszm.imslsh = 30 + 15 - k + 1;              //秒数流水号
                        objsdszm.itrun = itrun;        //逐秒发动机转速
                        objsdszm.m_iHc = m_mainform.objfqy.m_iHc;                 //逐秒HC浓度值(未经修正)
                        objsdszm.m_fCo = m_mainform.objfqy.m_fCo;                 //逐秒CO浓度值(未经修正)
                        objsdszm.m_fCo2 = m_mainform.objfqy.m_fCo2;               //逐秒CO2浓度值
                        objsdszm.m_iNo = m_mainform.objfqy.m_iNo;                 //
                        objsdszm.m_fO2 = m_mainform.objfqy.m_fO2;                 //逐秒O2浓度值
                        objsdszm.m_fLamda = m_mainform.objfqy.m_fLamda;          //逐秒计算的λ值
                        objsdszm.m_fWenDu = m_mainform.objfqy.m_fWenDu;     //测试工况环境温度每秒数据
                        objsdszm.m_fYaLi = m_mainform.objfqy.m_fYaLi;      //测试工况环境大气压力每秒数据
                        objsdszm.m_fShiDu = m_mainform.objfqy.m_fShiDu;        //测试工况环境相对湿度每秒数据
                        objsdszm.m_fyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);            //逐秒发动机机油温度
                        objsdszm.GKLX = "1";                     //工况过程类型
                        //objsdszm.ProcessTime = dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss");
                        //m_mainform.objbass.zmgcsjsds(businessId, objsdszm);
                        //if (m_mainform.sfOBD)
                        //{
                        //    m_mainform.objbass.sendOBDGCSJ(businessId, dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss"), objsdszm.imslsh);
                        //}
                        //igcsjcount++;
                        ////云景过程数据
                        //if (m_mainform.sconnetname.Contains("云景"))
                        //{
                        //    JsonData value = new LitJson.JsonData();
                        //    value["InspectionNum"] = businessId;
                        //    value["SceneCode"] = m_mainform.lineCode;
                        //    value["ProcessTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        //    value["Second_NO"] = 30 + 15 - k + 1;
                        //    value["Flow_RotateSpeed"] = itrun;
                        //    value["Flow_HC"] = m_mainform.objfqy.m_iHc;
                        //    value["Flow_CO"] = m_mainform.objfqy.m_fCo;
                        //    value["Flow_CO2"] = m_mainform.objfqy.m_fCo2;
                        //    value["Flow_NO"] = m_mainform.objfqy.m_iNo;
                        //    value["Flow_O2"] = m_mainform.objfqy.m_fO2;
                        //    value["Flow_Lambda"] = m_mainform.objfqy.m_fLamda;
                        //    value["EnvirTemperature"] = m_mainform.objfqy.m_fWenDu;
                        //    value["EnvirAirPressure"] = m_mainform.objfqy.m_fYaLi;
                        //    value["EnvirHumidity"] = m_mainform.objfqy.m_fShiDu;
                        //    value["EngineOilTemperature"] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                        //    value["GKLX"] = "1";

                        //    string svalue = value.ToJson();
                        //    sendSDSGCSJ(businessId, svalue);
                        //}
                        //

                        if (!bfs)
                        {
                            if (setlwgcsj())
                            {
                                bfs = true;
                            }
                        }
                        Thread.Sleep(300);
                        if (m_mainform.DateDiff(DateTime.Now, dstart) > 900)
                            break;

                    }
                    if (SDS_Stop)
                    {
                        m_mainform.flowwq.LedWrite("终止检测", "", 1);
                        sxianshineirong = string.Format(@"终止检测");
                        xianshixinxi();
                        return;
                    }
                }
                //图片


                m_mainform.objbass.uploadimage(businessId);
                m_mainform.objbass.zhuapai(businessId, shphm, shpzl, m_mainform.tongdaoqian, "wqq", "111");
                m_mainform.objbass.zhuapai(businessId, shphm, shpzl, m_mainform.tongdaohou, "wqh", "211");
                m_mainform.objbass.GetPic("111");
                m_mainform.objbass.GetPic("211");
                m_mainform.objbass.GetPic("11");
                //
                sxianshineirong = "高怠速," + (edzs * 0.5) .ToString("0")+ "±200转";
                xianshixinxi();
                {
                    string sshanghang = string.Format("高怠速," + (edzs * 0.5).ToString("0") + "±200转");
                    string sxiahang = string.Format("当前{0}剩{1}", itrun, 30);
                    m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                }
                for (int i = 0; i < 30; i++)//30
                {
                    DateTime dstart = DateTime.Now;

                    jyyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                    if (!m_mainform.getOBD_GCSJ(businessId))//读取OBD过程数据
                    {
                        sxianshineirong = "找不到OBD过程数据，请接好OBD再上线！";
                        xianshixinxi();
                        {
                            string sshanghang = string.Format("找不到OBD");
                            string sxiahang = string.Format("请接好OBD");
                            m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                        }
                        return;
                    }
                    bool bfs = false;
                    while (true)
                    {


                        //if (szsqz.Contains("废气仪"))
                        //{
                        //    itrun = m_mainform.m_iGasturn;
                        //}
                        //else
                        //{
                        //    itrun = m_mainform.m_iTurn;
                        //}

                        {
                            string sshanghang = string.Format("高怠速," + (edzs * 0.5).ToString("0") + "±200转");
                            string sxiahang = string.Format("当前{0}剩{1}", itrun, 30-i);
                            m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                        }
                        if (rbOBDZS.Checked)
                        {
                            int ifdjzs = 0;
                            int.TryParse(m_mainform.OBD_fdjzs, out ifdjzs);
                            itrun = ifdjzs;
                        }
                        else
                        {
                            itrun = m_mainform.objzsy.m_iGasturn;
                        }
                        //if (ssdszs.Contains("是"))
                        {
                            if ((itrun < (edzs * 0.5) - 200 || itrun > (edzs * 0.5) + 200))// && (itrun > 500))test
                            {
                                i = 0;
                                trun.ForeColor = Color.Red;
                            }
                            else
                            {
                                trun.ForeColor = Color.Green;
                            }
                        }
                        //else
                        //{
                        //    if (itrun < 500 && ssdszsyq!="否")
                        //    {
                        //        i = 0;
                        //        trun.ForeColor = Color.Red;
                        //    }
                        //    else if ((itrun < edzs - 200 || itrun > edzs + 200) )
                        //    {
                        //        itrun = 2400 + m_mainform.getRandom(1, 6) * 10;// +m_mainform.getRandom(0, 9);
                        //        trun.ForeColor = Color.Green;
                        //    }
                        //}

                        itime = 30 - i;
                        iHC = m_mainform.objfqy.m_iHc;
                        fCO = m_mainform.objfqy.m_fCo;
                        fCOCO2 = m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2;
                        xianshitrun();
                        xianshiYOUWEN();
                        xianshitime();
                        xianshiHC();
                        xianshiCO();
                        xianshiCOCO2();
                        m_HCGCSJG[i] = m_mainform.objfqy.m_iHc;
                        m_COGCSJG[i] = m_mainform.objfqy.m_fCo;
                        m_LAMDAGCSJG[i] = m_mainform.objfqy.m_fLamda;
                        inspectNum = inspectNum + i;


                        m_HCGCSJG[i] = m_mainform.objfqy.m_iHc;
                        m_COGCSJG[i] = m_mainform.objfqy.m_fCo;
                        m_O2GCSJG[i] = m_mainform.objfqy.m_fO2;
                        m_CO2GCSJG[i] = m_mainform.objfqy.m_fCo2;
                        m_LAMDAGCSJG[i] = m_mainform.objfqy.m_fLamda;
                        m_TrunGCSJG[i] = itrun;
                        m_ProcessTimeG[i] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                        //m_mainform.gethuanjing();
                        m_YWGCSJG[i] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                        m_NOGCSJG[i] = m_mainform.objfqy.m_iNo;

                        m_wendu[30 + 15 + i] = m_mainform.objfqy.m_fWenDu;
                        m_shidu[30 + 15 + i] = m_mainform.objfqy.m_fShiDu;
                        m_daqiya[30 + 15 + i] = m_mainform.objfqy.m_fYaLi;

                        iobd = 30 + 15 + i;
                        OBD_jqmkd[iobd] = m_mainform.OBD_jqmkd;
                        OBD_fh[iobd] = m_mainform.OBD_fh;
                        OBD_qycgqxh[iobd] = m_mainform.OBD_qycgqxh;
                        OBD_glkqxs[iobd] = m_mainform.OBD_glkqxs;
                        OBD_ymkd[iobd] = m_mainform.OBD_ymkd;
                        OBD_cs[iobd] = m_mainform.OBD_cs;
                        OBD_fdjzs[iobd] = m_mainform.OBD_fdjzs;
                        OBD_jql[iobd] = m_mainform.OBD_jql;
                        OBD_jqyl[iobd] = m_mainform.OBD_jqyl;
                        OBD_scgl[iobd] = m_mainform.OBD_scgl;
                        OBD_zyyl[iobd] = m_mainform.OBD_zyyl;
                        OBD_hyl[iobd] = m_mainform.OBD_hyl;
                        OBD_no[iobd] = m_mainform.OBD_no;
                        OBD_nsbsl[iobd] = m_mainform.OBD_nsbsl;
                        OBD_pqwd[iobd] = m_mainform.OBD_pqwd;
                        OBD_klbjqyc[iobd] = m_mainform.OBD_klbjqyc;
                        OBD_egrkd[iobd] = m_mainform.OBD_egrkd;
                        OBD_rypsyl[iobd] = m_mainform.OBD_rypsyl;
                        OBD_sjxl[iobd] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

                        m_mainform.baocunrijiGCSJ(string.Format("{0}双怠速高怠速过程数据日志", hphm.Text),
                       string.Format("HC:{0},CO:{1},LAMDA:{2},转速:{3},油温:{4},co+co2:{5}",
                       m_mainform.objfqy.m_iHc, m_mainform.objfqy.m_fCo, m_mainform.objfqy.m_fLamda, itrun, (byw ? fywrg : m_mainform.objfqy.m_fyw), (m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2)));

                        //model.SDS.SDSgcsjZM objsdszm = new model.SDS.SDSgcsjZM();
                        objsdszm.businessId = businessId;       //受理编码
                        objsdszm.lineCode = m_mainform.lineCode;            //检测站编码
                        objsdszm.jcgcdysj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //检测过程数据对应时间
                        //objsdszm.imslsh = 30 + 15 + i + 1;//秒数流水号
                        objsdszm.itrun = itrun;        //逐秒发动机转速
                        objsdszm.m_iHc = m_mainform.objfqy.m_iHc;                 //逐秒HC浓度值(未经修正)
                        objsdszm.m_fCo = m_mainform.objfqy.m_fCo;                 //逐秒CO浓度值(未经修正)
                        objsdszm.m_fCo2 = m_mainform.objfqy.m_fCo2;               //逐秒CO2浓度值
                        objsdszm.m_iNo = m_mainform.objfqy.m_iNo;                 //
                        objsdszm.m_fO2 = m_mainform.objfqy.m_fO2;                 //逐秒O2浓度值
                        objsdszm.m_fLamda = m_mainform.objfqy.m_fLamda;          //逐秒计算的λ值
                        objsdszm.m_fWenDu = m_mainform.objfqy.m_fWenDu;     //测试工况环境温度每秒数据
                        objsdszm.m_fYaLi = m_mainform.objfqy.m_fYaLi;      //测试工况环境大气压力每秒数据
                        objsdszm.m_fShiDu = m_mainform.objfqy.m_fShiDu;        //测试工况环境相对湿度每秒数据
                        objsdszm.m_fyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);            //逐秒发动机机油温度
                        objsdszm.GKLX = "2";                     //工况过程类型



                        if (!bfs)
                        {
                            if (setlwgcsj())
                            {
                                bfs = true;
                            }
                        }
                        if (diliulangyujing(m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2))
                        {
                            return;
                        }
                        Thread.Sleep(200);
                        if (m_mainform.DateDiff(DateTime.Now, dstart) > 900)
                            break;
                    }
                    if (SDS_Stop)
                    {
                        m_mainform.flowwq.LedWrite("终止检测", "", 1);
                        sxianshineirong = string.Format(@"终止检测");
                        xianshixinxi();
                        return;
                    }
                    gdsfdjzs = itrun;
                }



                for (int i = 0; i < 30; i++)
                {
                    iHCG = iHCG + m_HCGCSJG[i];
                    fCOG = fCOG + m_COGCSJG[i];
                    fLAMDAG = fLAMDAG + m_LAMDAGCSJG[i];
                    fCO2H = fCO2H + m_CO2GCSJG[i];//   
                    fRevH = fRevH + m_TrunGCSJG[i];//
                }
                iHCG = iHCG / 30;
                fCOG = fCOG / 30f;
                fLAMDAG = fLAMDAG / 30f;

                fCO2H = fCO2H / 30f;//   
                fRevH = fRevH / 30;//


                //if (fLAMDAG < 0.95)
                //    fLAMDAG = 0.98f;
                //else if (fLAMDAG > 1.05)
                //    fLAMDAG = 1.02f;

                xianshiHCG();
                xianshiCOG();
                xianshiLAMDAG();


                //判断
                if (iHCG > m_mainform.HIHCL || fCOG > m_mainform.HICOL || (!bydhh && (fLAMDAG > 1.05f || fLAMDAG < 0.95f)))//test
                //  if (iHCG > m_mainform.HIHCL || fCOG > m_mainform.HICOL )
                //if (true)
                {
                    bthread3 = true;

                    if (!bydhh&&(fLAMDAG > 1.05f || fLAMDAG < 0.95f))
                    {
                        ilandapd = 0;
                    }
                    lamda = fLAMDAG.ToString("0.00");
                    bgood = false;

                    sxianshineirong = "检测结束 检测不合格";
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("检测结束");
                        string sxiahang = string.Format("检测不合格");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }

                    itime = 0;
                    xianshitime();
                    Thread.Sleep(1500);
                    m_mainform.objfqy.SendDeviceCmd(2);//停止测量
                    Thread.Sleep(1500);
                    m_mainform.objfqy.SendDeviceCmd(4);//反吹
                    //m_mainform.SendDeviceCmdGas(0x7A, 0x81);//停止测量
                    //Thread.Sleep(500);
                    //m_mainform.SendDeviceCmdGas(0x65, 0x96);

                    timeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    ///保存数据到数据库中。
                    #region 数据结果保存到数据库
                    string sqlsds = string.Format(@"update Detects_SJE set 
                                                HCO={0},
                                                HHC={1},
                                                HLAMDA={2},
                                                LCO={3},
                                                LHC={4},
                                                GasWenDu={5},
                                                GasShiDu={6},
                                                GasYaLi={7},
                                                Time_begin='{8}',
                                                Time_end='{9}' ,
                                                WQPD={10}
                                                 where DETECT_ID={11}  or ASM_JYLSH='{12}' ",
                                               fCOG,
                                               iHCG,
                                               fLAMDAG,
                                               fCOD,
                                               iHCD,
                                               wendu.Text,
                                               shidu.Text,
                                               daqiya.Text,
                                               timeStart,
                                               timeEnd,
                                               2,
                                               DETECT_ID,
                                               businessId);
                    m_mainform.objbass.objdb.InsertDB(sqlsds);
                    #endregion
                    //

                    ///保存过程数据
                    //记录双怠速过程数据
                    baocunGCSJ_SDS(businessId, m_mainform.testtimes, false);
                    baocunGCSJ_OBD(businessId);

                    //if (m_mainform.sconnetname.Contains("安车"))
                    //{
                    //    sdslwac(false);
                    //}
                    //else if (m_mainform.sconnetname.Contains("智慧"))//旧联网模式
                    //{
                    //    sdslwzh(false);
                    //}
                    //else //if (m_mainform.sconnetname.Contains("yunjingjiu"))
                    {
                       bfh= sdslwyjj(false);
                        m_mainform.objbass.XXTZ("05");
                    }
                    // 保存过程数据到本地数据库
                    m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaoqian, "wqq");
                    m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaohou, "wqh");
                    m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaozhong, "wqqj");
                    m_mainform.objbass.GetPIC("111");//高怠速第一秒拍照点前照
                    m_mainform.objbass.GetPIC("112");//怠速第一秒拍照点前照
                    m_mainform.objbass.GetPIC("113");//怠速最后一秒拍照点前照
                    m_mainform.objbass.GetPIC("211");//高怠速第一秒拍照点后照
                    m_mainform.objbass.GetPIC("212");//怠速第一秒拍照点后照
                    m_mainform.objbass.GetPIC("213");//怠速最后一秒拍照点后照
                    m_mainform.objbass.LuXiang("01", "http://193.112.138.21:8011/media/20181121/20181121001_1_h0.mp4");
                    m_mainform.objbass.LuXiang("02", "http://193.112.138.21:8011/media/20181121/20181121001_1_h0.mp4");
                    m_mainform.objbass.LuXiang("03", "http://193.112.138.21:8011/media/20181121/20181121001_1_h0.mp4");
                    if (bfh)
                    {
                        m_mainform.insertjcwc(businessId);
                        sendSDSstop(businessId);
                    }
                    
                    Thread.Sleep(3000);
                    thisclose();

                    return;
                }



                //
                {
                    //减速到怠速
                    sxianshineirong = "减速至怠速，进行怠速检测";
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("减速至怠速");
                        string sxiahang = string.Format("进行怠速检测");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    for (int k = 0; k < 15; k++)//取数平稳//15
                    {
                        {
                            string sshanghang = string.Format("减速至怠速");
                            string sxiahang = string.Format("当前{0}剩{1}", itrun, 15 - k);
                            m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                        }
                        DateTime dstart = DateTime.Now;

                        if (!m_mainform.getOBD_GCSJ(businessId))//读取OBD过程数据
                        {
                            sxianshineirong = "找不到OBD过程数据，请接好OBD再上线！";
                            xianshixinxi();
                            {
                                string sshanghang = string.Format("找不到OBD");
                                string sxiahang = string.Format("请接好OBD");
                                m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                            }
                            return;
                        }
                        bool bfs = false;
                        while (true)
                        {


                            //if (szsqz.Contains("废气仪"))
                            //{
                            //    itrun = m_mainform.m_iGasturn;
                            //}
                            //else
                            //{
                            //    itrun = m_mainform.m_iTurn;
                            //}
                            if (rbOBDZS.Checked)
                            {
                                int ifdjzs = 0;
                                int.TryParse(m_mainform.OBD_fdjzs, out ifdjzs);
                                itrun = ifdjzs;
                            }
                            else
                            {
                                itrun = m_mainform.objzsy.m_iGasturn;
                            }
                            itime = 15 - k;
                            xianshitrun();
                            xianshiYOUWEN();
                            xianshitime();

                            m_HCGCSJD15[k] = m_mainform.objfqy.m_iHc;
                            m_COGCSJD15[k] = m_mainform.objfqy.m_fCo;
                            m_O2GCSJD15[k] = m_mainform.objfqy.m_fO2;
                            m_CO2GCSJD15[k] = m_mainform.objfqy.m_fCo2;
                            m_LAMDAGCSJD15[k] = m_mainform.objfqy.m_fLamda;
                            m_TrunGCSJD15[k] = itrun;
                            m_ProcessTimeD15[k] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //m_mainform.gethuanjing();
                            m_YWGCSJD15[k] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                            m_NOGCSJD15[k] = m_mainform.objfqy.m_iNo;

                            m_wendu[60 + 15 + k] = m_mainform.objfqy.m_fWenDu;
                            m_shidu[60 + 15 + k] = m_mainform.objfqy.m_fShiDu;
                            m_daqiya[60 + 15 + k] = m_mainform.objfqy.m_fYaLi;

                            iobd = 60 + 15 + k;
                            OBD_jqmkd[iobd] = m_mainform.OBD_jqmkd;
                            OBD_fh[iobd] = m_mainform.OBD_fh;
                            OBD_qycgqxh[iobd] = m_mainform.OBD_qycgqxh;
                            OBD_glkqxs[iobd] = m_mainform.OBD_glkqxs;
                            OBD_ymkd[iobd] = m_mainform.OBD_ymkd;
                            OBD_cs[iobd] = m_mainform.OBD_cs;
                            OBD_fdjzs[iobd] = m_mainform.OBD_fdjzs;
                            OBD_jql[iobd] = m_mainform.OBD_jql;
                            OBD_jqyl[iobd] = m_mainform.OBD_jqyl;
                            OBD_scgl[iobd] = m_mainform.OBD_scgl;
                            OBD_zyyl[iobd] = m_mainform.OBD_zyyl;
                            OBD_hyl[iobd] = m_mainform.OBD_hyl;
                            OBD_no[iobd] = m_mainform.OBD_no;
                            OBD_nsbsl[iobd] = m_mainform.OBD_nsbsl;
                            OBD_pqwd[iobd] = m_mainform.OBD_pqwd;
                            OBD_klbjqyc[iobd] = m_mainform.OBD_klbjqyc;
                            OBD_egrkd[iobd] = m_mainform.OBD_egrkd;
                            OBD_rypsyl[iobd] = m_mainform.OBD_rypsyl;
                            OBD_sjxl[iobd] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                            m_mainform.baocunrijiGCSJ(string.Format("{0}双怠速怠速过程数据日志", hphm.Text),
                      string.Format("HC:{0},CO:{1},LAMDA:{2},转速:{3},油温:{4},co+co2:{5}",
                      m_mainform.objfqy.m_iHc, m_mainform.objfqy.m_fCo, m_mainform.objfqy.m_fLamda, itrun, (byw ? fywrg : m_mainform.objfqy.m_fyw), (m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2)));

                            //model.SDS.SDSgcsjZM objsdszm = new model.SDS.SDSgcsjZM();
                            objsdszm.businessId = businessId;       //受理编码
                            objsdszm.lineCode = m_mainform.lineCode;            //检测站编码
                            objsdszm.jcgcdysj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //检测过程数据对应时间
                            //objsdszm.imslsh = 60 + 15 + k + 1;//秒数流水号
                            objsdszm.itrun = itrun;        //逐秒发动机转速
                            objsdszm.m_iHc = m_mainform.objfqy.m_iHc;                 //逐秒HC浓度值(未经修正)
                            objsdszm.m_fCo = m_mainform.objfqy.m_fCo;                 //逐秒CO浓度值(未经修正)
                            objsdszm.m_fCo2 = m_mainform.objfqy.m_fCo2;               //逐秒CO2浓度值
                            objsdszm.m_iNo = m_mainform.objfqy.m_iNo;                 //
                            objsdszm.m_fO2 = m_mainform.objfqy.m_fO2;                 //逐秒O2浓度值
                            objsdszm.m_fLamda = m_mainform.objfqy.m_fLamda;          //逐秒计算的λ值
                            objsdszm.m_fWenDu = m_mainform.objfqy.m_fWenDu;     //测试工况环境温度每秒数据
                            objsdszm.m_fYaLi = m_mainform.objfqy.m_fYaLi;      //测试工况环境大气压力每秒数据
                            objsdszm.m_fShiDu = m_mainform.objfqy.m_fShiDu;        //测试工况环境相对湿度每秒数据
                            objsdszm.m_fyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);            //逐秒发动机机油温度
                            objsdszm.GKLX = "3";                     //工况过程类型
                            //objsdszm.ProcessTime = dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss");
                            //m_mainform.objbass.zmgcsjsds(businessId, objsdszm);
                            //if (m_mainform.sfOBD)
                            //{
                            //    m_mainform.objbass.sendOBDGCSJ(businessId, dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss"), objsdszm.imslsh);
                            //}
                            //igcsjcount++;
                            ////云景过程数据
                            //if (m_mainform.sconnetname.Contains("云景"))
                            //{
                            //    JsonData value = new LitJson.JsonData();
                            //    value["InspectionNum"] = businessId;
                            //    value["SceneCode"] = m_mainform.lineCode;
                            //    value["ProcessTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //    value["Second_NO"] = 60 + 15 + k + 1;
                            //    value["Flow_RotateSpeed"] = itrun;
                            //    value["Flow_HC"] = m_mainform.objfqy.m_iHc;
                            //    value["Flow_CO"] = m_mainform.objfqy.m_fCo;
                            //    value["Flow_CO2"] = m_mainform.objfqy.m_fCo2;
                            //    value["Flow_NO"] = m_mainform.objfqy.m_iNo;
                            //    value["Flow_O2"] = m_mainform.objfqy.m_fO2;
                            //    value["Flow_Lambda"] = m_mainform.objfqy.m_fLamda;
                            //    value["EnvirTemperature"] = m_mainform.objfqy.m_fWenDu;
                            //    value["EnvirAirPressure"] = m_mainform.objfqy.m_fYaLi;
                            //    value["EnvirHumidity"] = m_mainform.objfqy.m_fShiDu;
                            //    value["EngineOilTemperature"] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                            //    value["GKLX"] = "3";

                            //    string svalue = value.ToJson();
                            //    sendSDSGCSJ(businessId, svalue);
                            //}
                            ////


                            if (!bfs)
                            {
                                if (setlwgcsj())
                                {
                                    bfs = true;
                                }
                            }
                            if (diliulangyujing(m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2))
                            {
                                return;
                            }


                            Thread.Sleep(200);
                            if (m_mainform.DateDiff(DateTime.Now, dstart) > 900)
                                break;

                        }
                        if (SDS_Stop)
                        {
                            m_mainform.flowwq.LedWrite("终止检测", "", 1);
                            sxianshineirong = string.Format(@"终止检测");
                            xianshixinxi();
                            return;
                        }
                    }
                    sxianshineirong = "怠速检测";
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("怠速检测");
                        string sxiahang = string.Format("");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }

                    m_mainform.objbass.GetPic("12");
                    m_mainform.objbass.zhuapai(businessId, shphm, shpzl, m_mainform.tongdaoqian, "wqq", "112");
                    m_mainform.objbass.zhuapai(businessId, shphm, shpzl, m_mainform.tongdaohou, "wqh", "212");
                    m_mainform.objbass.GetPic("112");
                    m_mainform.objbass.GetPic("212");

                    for (int i = 0; i < 30; i++)
                    {
                        DateTime dstart = DateTime.Now;

                        if (!m_mainform.getOBD_GCSJ(businessId))//读取OBD过程数据
                        {
                            sxianshineirong = "找不到OBD过程数据，请接好OBD再上线！";
                            xianshixinxi();
                            {
                                string sshanghang = string.Format("找不到OBD");
                                string sxiahang = string.Format("请接好OBD");
                                m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                            }
                            return;
                        }
                        bool bfs = false;
                        while (true)
                        {
                            {
                                string sshanghang = string.Format("怠速检测");
                                string sxiahang = string.Format("当前{0}剩{1}", itrun, 30 - i);
                                m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                            }
                            //if (szsqz.Contains("废气仪"))
                            //{
                            //    itrun = m_mainform.m_iGasturn;
                            //}
                            //else
                            //{
                            //    itrun = m_mainform.m_iTurn;
                            //}
                            if (rbOBDZS.Checked)
                            {
                                int ifdjzs = 0;
                                int.TryParse(m_mainform.OBD_fdjzs, out ifdjzs);
                                itrun = ifdjzs;
                            }
                            else
                            {
                                itrun = m_mainform.objzsy.m_iGasturn;
                            }
                            itime = 30 - i;
                            iHC = m_mainform.objfqy.m_iHc;
                            fCO = m_mainform.objfqy.m_fCo;
                            fO2 = m_mainform.objfqy.m_fO2;
                            fCOCO2 = m_mainform.objfqy.m_fCo + m_mainform.objfqy.m_fCo2;
                            xianshitrun();
                            xianshiYOUWEN();
                            xianshitime();
                            xianshiHC();
                            xianshiCO();
                            xianshiCOCO2();
                            m_HCGCSJD[i] = m_mainform.objfqy.m_iHc;
                            m_COGCSJD[i] = m_mainform.objfqy.m_fCo;
                            inspectNum = inspectNum + i;

                            m_HCGCSJD[i] = m_mainform.objfqy.m_iHc;
                            m_COGCSJD[i] = m_mainform.objfqy.m_fCo;
                            m_O2GCSJD[i] = m_mainform.objfqy.m_fO2;
                            m_CO2GCSJD[i] = m_mainform.objfqy.m_fCo2;
                            m_LAMDAGCSJD[i] = m_mainform.objfqy.m_fLamda;
                            m_TrunGCSJD[i] = itrun;
                            m_ProcessTimeD[i] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                            //m_mainform.gethuanjing();
                            m_YWGCSJD[i] = (byw ? fywrg : m_mainform.objfqy.m_fyw);
                            m_NOGCSJD[i] = m_mainform.objfqy.m_iNo;

                            m_wendu[60 + 15 + 15 + i] = m_mainform.objfqy.m_fWenDu;
                            m_shidu[60 + 15 + 15 + i] = m_mainform.objfqy.m_fShiDu;
                            m_daqiya[60 + 15 + 15 + i] = m_mainform.objfqy.m_fYaLi;

                            iobd = 60 + 15 + 15 + i;
                            OBD_jqmkd[iobd] = m_mainform.OBD_jqmkd;
                            OBD_fh[iobd] = m_mainform.OBD_fh;
                            OBD_qycgqxh[iobd] = m_mainform.OBD_qycgqxh;
                            OBD_glkqxs[iobd] = m_mainform.OBD_glkqxs;
                            OBD_ymkd[iobd] = m_mainform.OBD_ymkd;
                            OBD_cs[iobd] = m_mainform.OBD_cs;
                            OBD_fdjzs[iobd] = m_mainform.OBD_fdjzs;
                            OBD_jql[iobd] = m_mainform.OBD_jql;
                            OBD_jqyl[iobd] = m_mainform.OBD_jqyl;
                            OBD_scgl[iobd] = m_mainform.OBD_scgl;
                            OBD_zyyl[iobd] = m_mainform.OBD_zyyl;
                            OBD_hyl[iobd] = m_mainform.OBD_hyl;
                            OBD_no[iobd] = m_mainform.OBD_no;
                            OBD_nsbsl[iobd] = m_mainform.OBD_nsbsl;
                            OBD_pqwd[iobd] = m_mainform.OBD_pqwd;
                            OBD_klbjqyc[iobd] = m_mainform.OBD_klbjqyc;
                            OBD_egrkd[iobd] = m_mainform.OBD_egrkd;
                            OBD_rypsyl[iobd] = m_mainform.OBD_rypsyl;
                            OBD_sjxl[iobd] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");


                            dsfdjzs = itrun;



                            //model.SDS.SDSgcsjZM objsdszm = new model.SDS.SDSgcsjZM();
                            objsdszm.businessId = businessId;       //受理编码
                            objsdszm.lineCode = m_mainform.lineCode;            //检测站编码
                            objsdszm.jcgcdysj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //检测过程数据对应时间
                            objsdszm.imslsh = 60 + 15 + 15 + i + 1;              //秒数流水号
                            objsdszm.itrun = itrun;        //逐秒发动机转速
                            objsdszm.m_iHc = m_mainform.objfqy.m_iHc;                 //逐秒HC浓度值(未经修正)
                            objsdszm.m_fCo = m_mainform.objfqy.m_fCo;                 //逐秒CO浓度值(未经修正)
                            objsdszm.m_fCo2 = m_mainform.objfqy.m_fCo2;               //逐秒CO2浓度值
                            objsdszm.m_iNo = m_mainform.objfqy.m_iNo;                 //
                            objsdszm.m_fO2 = m_mainform.objfqy.m_fO2;                 //逐秒O2浓度值
                            objsdszm.m_fLamda = m_mainform.objfqy.m_fLamda;          //逐秒计算的λ值
                            objsdszm.m_fWenDu = m_mainform.objfqy.m_fWenDu;     //测试工况环境温度每秒数据
                            objsdszm.m_fYaLi = m_mainform.objfqy.m_fYaLi;      //测试工况环境大气压力每秒数据
                            objsdszm.m_fShiDu = m_mainform.objfqy.m_fShiDu;        //测试工况环境相对湿度每秒数据
                            objsdszm.m_fyw = (byw ? fywrg : m_mainform.objfqy.m_fyw);            //逐秒发动机机油温度
                            objsdszm.GKLX = "4";                     //工况过程类型


                            if (!bfs)
                            {
                                if (setlwgcsj())
                                {
                                    bfs = true;
                                }
                            }
                            Thread.Sleep(200);
                            if (m_mainform.DateDiff(DateTime.Now, dstart) > 900)
                                break;
                        }
                        if (SDS_Stop)
                        {
                            m_mainform.flowwq.LedWrite("终止检测", "", 1);
                            sxianshineirong = string.Format(@"终止检测");
                            xianshixinxi();
                            return;
                        }
                    }
                    bthread3 = true;

                    m_mainform.objbass.GetPic("13");
                    m_mainform.objbass.zhuapai(businessId, shphm, shpzl, m_mainform.tongdaoqian, "wqq", "113");
                    m_mainform.objbass.zhuapai(businessId, shphm, shpzl, m_mainform.tongdaohou, "wqh", "213");
                    m_mainform.objbass.GetPic("113");
                    m_mainform.objbass.GetPic("213");

                    itime = 0;
                    itrun = 0;
                    xianshitrun();
                    xianshiYOUWEN();
                    xianshitime();



                    for (int i = 0; i < 30; i++)
                    {

                        iHCD = iHCD + m_HCGCSJD[i];
                        fCOD = fCOD + m_COGCSJD[i];
                        fCO2 = fCO2 + m_CO2GCSJD[i];
                        fRev = fRev + m_TrunGCSJD[i];
                    }

                    iHCD = iHCD / 30;
                    fCOD = fCOD / 30f;

                    fCO2 = fCO2 / 30f;//   m_CO2GCSJD[i] ;
                    fRev = fRev / 30;//+   m_TrunGCSJD[i] ;

                    xianshiHCD();
                    xianshiCOD();

                    sxianshineirong = "双怠速检测结束";
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("双怠速检测结束");
                        string sxiahang = string.Format("");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }

                    itime = 0;
                    xianshitime();


                    bdushu = false;

                    Thread.Sleep(1500);
                    m_mainform.objfqy.SendDeviceCmd(2);//停止测量
                    Thread.Sleep(1500);
                    m_mainform.objfqy.SendDeviceCmd(4);//反吹
                    //m_mainform.SendDeviceCmdGas(0x7A, 0x81);//停止测量
                    //Thread.Sleep(500);
                    //m_mainform.SendDeviceCmdGas(0x65, 0x96);

                   


                    timeEnd = DateTime.Now.ToLocalTime().ToString();



                    //bool bgood = true;
                    if (iHCG > m_mainform.HIHCL || fCOG > m_mainform.HICOL || iHCD > m_mainform.LIHCL || fCOD > m_mainform.LICOL ||(!bydhh&&( fLAMDAG > 1.05 || fLAMDAG < 0.95)))
                    {
                        bgood = false;
                    }
                    if (bgood)
                    {
                        sxianshineirong = "检测合格 ";
                    }
                    else
                    {
                        sxianshineirong = "检测不合格 ";
                    }


                    if (!bydhh && (fLAMDAG > 1.05 || fLAMDAG < 0.95))
                    {
                        ilandapd = 0;
                    }
                    lamda = fLAMDAG.ToString("0.00");

                    xianshixinxi();
                    {
                        string sshanghang = string.Format("{0}", sxianshineirong);
                        string sxiahang = string.Format("");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }

                    timeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    ///保存数据到数据库中。
                    ///

                    ///保存数据到数据库中。
                    #region 数据结果保存到数据库
                    string sqlsds = string.Format(@"update Detects_SJE set 
                                                HCO={0},
                                                HHC={1},
                                                HLAMDA={2},
                                                LCO={3},
                                                LHC={4},
                                                GasWenDu={5},
                                                GasShiDu={6},
                                                GasYaLi={7},
                                                Time_begin='{8}',
                                                Time_end='{9}' ,
                                                WQPD={10}
                                                where DETECT_ID={11}  or ASM_JYLSH='{12}'",
                                               fCOG,
                                               iHCG,
                                               fLAMDAG,
                                               fCOD,
                                               iHCD,
                                               wendu.Text,
                                               shidu.Text,
                                               daqiya.Text,
                                               timeStart,
                                               timeEnd,
                                               bgood?"1":"2",
                                               DETECT_ID,
                                               businessId);
                    m_mainform.objbass.objdb.InsertDB(sqlsds);//检测结果

                    //过程数据

                    // string sqlgcsj = string.Format(@"");


                    #endregion
                    //
                    ///保存过程数据
                    //记录双怠速过程数据
                    baocunGCSJ_SDS(businessId, m_mainform.testtimes, true);
                    baocunGCSJ_OBD(businessId);
                    // 保存过程数据到本地数据库

                    //if (m_mainform.sconnetname.Contains("安车"))
                    //{
                    //    sdslwac(true);
                    //}
                    //else if (m_mainform.sconnetname.Contains("智慧"))//旧联网模式
                    //{
                    //    sdslwzh(false);
                    //}
                    //else //if (m_mainform.sconnetname.Contains("yunjingjiu"))
                    {
                       bfh = sdslwyjj(false);
                        m_mainform.objbass.XXTZ("05");
                    }
                 
                    m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaoqian, "wqq");
                    m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaohou, "wqh");
                    m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaozhong, "wqqj");
                    m_mainform.objbass.GetPIC("111");//高怠速第一秒拍照点前照
                    m_mainform.objbass.GetPIC("112");//怠速第一秒拍照点前照
                    m_mainform.objbass.GetPIC("113");//怠速最后一秒拍照点前照
                    m_mainform.objbass.GetPIC("211");//高怠速第一秒拍照点后照
                    m_mainform.objbass.GetPIC("212");//怠速第一秒拍照点后照
                    m_mainform.objbass.GetPIC("213");//怠速最后一秒拍照点后照
                    m_mainform.objbass.LuXiang("01", "http://193.112.138.21:8011/media/20181121/20181121001_1_h0.mp4");
                    m_mainform.objbass.LuXiang("02", "http://193.112.138.21:8011/media/20181121/20181121001_1_h0.mp4");
                    m_mainform.objbass.LuXiang("03", "http://193.112.138.21:8011/media/20181121/20181121001_1_h0.mp4");

                    
                    Thread.Sleep(3000);
                    if (bfh)
                    {
                        m_mainform.insertjcwc(businessId);
                        sendSDSstop(businessId);
                    }
                    thisclose();

                }
            }
            //catch (Exception ex)
            //{
            //    m_mainform.baocunriji("双怠速", ex.Message.ToString());
            //}


        }

        private void TESTSDS_Resize(object sender, EventArgs e)
        {
            float newx = (this.Width) / x;
            float newy = (this.Height) / y;
            setControls(newx, newy, this);
        }

       
        public double floTodou(float m_float)
        {
            double m_dou = 0;
            double.TryParse(string.Format("{0}", m_float), out m_dou);
            return m_dou;
        }
        public double intTodou(int m_float)
        {
            double m_dou = 0;
            double.TryParse(string.Format("{0}", m_float), out m_dou);
            return m_dou;
        }

        private void zhongzhijiance_Click(object sender, EventArgs e)
        {
            SDS_Stop = true;
            //Thread.Sleep(1000);
            //m_mainform.SendDeviceCmdGas(0x7A, 0x81);//停止测量
            //Thread.Sleep(500);
            //m_mainform.SendDeviceCmdGas(0x65, 0x96);//反吹

            Thread.Sleep(1500);
            m_mainform.objfqy.SendDeviceCmd(2);//停止测量
            Thread.Sleep(1500);
            m_mainform.objfqy.SendDeviceCmd(4);//反吹
            this.Close();

        }

        private void TESTSDS_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (SDS_Start)
            {
                t1.Abort();
                t1.DisableComObjectEagerCleanup();

                //t2.Abort();
                //t2.DisableComObjectEagerCleanup();


                t3.Abort();
                t3.DisableComObjectEagerCleanup();

            }

        }
        public bool diliulangyujing(float fcoco2)
        {
            //m_mainform.m_fDLLYJ = false;
            m_mainform.objfqy.m_fDLLYJ = false;
            if (m_mainform.objfqy.SendDeviceCmd(6))
            //if (m_mainform.SendDeviceCmdGas(0x61, 0x9A))
            {
                Thread.Sleep(250);
                if (m_mainform.objfqy.m_fDLLYJ)
                {
                    xinxixianshi.ForeColor = Color.Red;
                    sxianshineirong = string.Format("管道堵塞，流量过低");
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("管道堵塞流量过低");
                        string sxiahang = string.Format("停止检测请减速");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    Thread.Sleep(3000);
                    sxianshineirong = string.Format("停止检测请减速");
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("管道堵塞流量过低");
                        string sxiahang = string.Format("停止检测请减速");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    for (; ; )
                    {
                        if (m_mainform.m_fspeed < 1)
                        {
                            break;
                        }
                    }

                    return true;
                }
                //else
                //{
                //    return false;
                //}
            }
            if (sASMllgd.Contains("是"))
            {

                if (fcoco2 < 6)
                {
                    xinxixianshi.ForeColor = Color.Red;
                    // sxianshineirong = string.Format("采样探头已掉落!!!");
                    sxianshineirong = string.Format("CO+CO2之和小于6");
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("CO+CO2之和小于6");
                        string sxiahang = string.Format("停止检测请减速");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    Thread.Sleep(3000);
                    sxianshineirong = string.Format("停止检测请减速");
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("CO+CO2之和小于6");
                        string sxiahang = string.Format("停止检测请减速");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    for (; ; )
                    {
                        if (m_mainform.m_fspeed < 1)
                        {
                            break;
                        }
                    }

                    return true;
                }
            }
            
            {
                return false;
            }
        }



        private void skinBut_ksjc_Click(object sender, EventArgs e)
        {        
            bthread3 = false;
            bthread_time = false;
            bsenddate = false;
            sendDate = DateTime.Now;
            sendDate2 = DateTime.Now;
            dtgcsj = DateTime.Now;
            igcsjcount_obd = 1;
            igcsjcount = 1;
            m_mainform.objfqy.SendDeviceCmd(3);
            model.尾气自检.检测前自检.zijiansds objzj = new model.尾气自检.检测前自检.zijiansds();

            objzj.dtBeginTime = DateTime.Now.AddMinutes(-3).ToString("yyyy-MM-dd HH:mm:ss");
            objzj.dtEndTime = DateTime.Now.AddMinutes(-1).ToString("yyyy-MM-dd HH:mm:ss");
            objzj.nCheckResult = "1";
            objzj.fEnvTemperature = m_mainform.objfqy.m_fWenDu.ToString();
            objzj.fEnvHumidity = m_mainform.objfqy.m_fShiDu.ToString();
            objzj.fEnvPressure = m_mainform.objfqy.m_fYaLi.ToString();
            objzj.nEnvTemperatureOK = "1";
            objzj.nEnvHumidityOK = "1";
            objzj.nEnvPressureOK = "1";
            objzj.dtZeroBeginTime = DateTime.Now.AddMinutes(-1).ToString("yyyy-MM-dd HH:mm:ss");
            objzj.dtZeroEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            objzj.fEnviHC = "0";
            objzj.fEnviCO = "0";
            objzj.fEnviNOx = "0";
            objzj.nEnviCheckOK = "1";
            objzj.fGasHC = "0";
            objzj.fGasCO = "0";
            objzj.fGasNOx = "0";
            objzj.fGasCheckOK = "1";
            objzj.nFlowCheckOK = "1";
            m_mainform.objbass.jianceqianzj(businessId, objzj);

            m_mainform.objbass.BgAirHC();//HC上传

            if (m_mainform.objbass.start(businessId, "", "", "", bobdhg) == "0")
                return;
            m_mainform.objbass.luxiangkaishi(businessId, shphm, shpzl, m_mainform.tongdaoqian, "wqq");//智慧
            m_mainform.objbass.luxiangkaishi(businessId, shphm, shpzl, m_mainform.tongdaohou, "wqh");//智慧
            m_mainform.objbass.luxiangkaishi(businessId, shphm, shpzl, m_mainform.tongdaozhong, "wqqj");//智慧

            bydhh = m_mainform.objbass.bydhh;
            objsdsgcsj = new model.SDS.SDSgcsj();
            objsdssj = new model.SDS.SDSsj();
            skinBut_ksjc.Enabled = false;
            t1 = new Thread(new ThreadStart(Thread1));
            t1.Priority = ThreadPriority.BelowNormal;
            t1.Start();

            t2 = new Thread(new ThreadStart(Thread2));
            t2.Priority = ThreadPriority.Lowest;


            t3 = new Thread(new ThreadStart(Thread3));
            t3.Priority = ThreadPriority.Lowest;
            t3.Start();


        }

        private void skinBut_zjjc_Click(object sender, EventArgs e)
        {

            控制流程.flowcrtl.iquanjuzhuangtai = 0; 
            bthread3 = true;
            SDS_Stop = true;
            //Thread.Sleep(1000);
            //m_mainform.SendDeviceCmdGas(0x7A, 0x81);//停止测量
            //Thread.Sleep(500);
            //m_mainform.SendDeviceCmdGas(0x65, 0x96);//反吹
            m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaoqian, "wqq");
            m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaohou, "wqh");
            m_mainform.objbass.luxiangjieshu(businessId, m_mainform.tongdaozhong, "wqqj");

            Thread.Sleep(1500);
            m_mainform.objfqy.SendDeviceCmd(2);//停止测量
            Thread.Sleep(1500);
            m_mainform.objfqy.SendDeviceCmd(4);//反吹
            this.Close();
        }

        private void skinBut_sz_Click(object sender, EventArgs e)
        {
            SDSPeiZhi obj = new SDSPeiZhi();
            obj.ShowDialog();
        }

        //记录双怠速过程数据
        public void baocunGCSJ_SDS(string sjylsh, string stime, bool dds)
        {
            string cysx = "";
            string hcclz = "";
            string zs = "";
            string coclz = "";
            string glkqxs = "";
            string yw = "";
            string co2clz = "";
            string o2clz = "";
            string hjwd = "";
            string dqyl = "";
            string xdsd = "";
            string sjxl = "";
            string jczt = "";


            for (int i = 0; i < 30; i++)
            {
                if (i == 0)
                {

                    cysx = string.Format(@"{0}", i + 1);
                    hcclz = string.Format(@"{0}", m_HCGCSJYR[i]);
                    zs = string.Format(@"{0}", m_TrunGCSJYR[i]);
                    coclz = string.Format(@"{0}", m_COGCSJYR[i]);
                    glkqxs = string.Format(@"{0}", m_LAMDAGCSJYR[i]);
                    yw = string.Format(@"{0}", m_YWGCSJYR[i] > 80 ? m_YWGCSJYR[i] : 85.3);
                    co2clz = string.Format(@"{0}", m_CO2GCSJYR[i]);
                    o2clz = string.Format(@"{0}", m_O2GCSJYR[i]);
                    hjwd = string.Format(@"{0}", m_wendu[i]);
                    dqyl = string.Format(@"{0}", m_daqiya[i]);
                    xdsd = string.Format(@"{0}", m_shidu[i]);
                    sjxl = string.Format(@"{0}", m_ProcessTimeYR[i]);
                    jczt = string.Format(@"{0}", 0);
                }
                else
                {
                    cysx = cysx + "," + string.Format(@"{0}", i + 1);
                    hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJYR[i]);
                    zs = zs + "," + string.Format(@"{0}", m_TrunGCSJYR[i]);
                    coclz = coclz + "," + string.Format(@"{0}", m_COGCSJYR[i]);
                    glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJYR[i]);
                    yw = yw + "," + string.Format(@"{0}", m_YWGCSJYR[i] > 80 ? m_YWGCSJYR[i] : 85.3);
                    co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJYR[i]);
                    o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJYR[i]);
                    hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[i]);
                    dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[i]);
                    xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[i]);
                    sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeYR[i]);
                    jczt = jczt + "," + string.Format(@"{0}", 0);
                }
            }
            for (int i = 0; i < 15; i++)
            {

                cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30);
                hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJG15[i]);
                zs = zs + "," + string.Format(@"{0}", m_TrunGCSJG15[i]);
                coclz = coclz + "," + string.Format(@"{0}", m_COGCSJG15[i]);
                glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJG15[i]);
                yw = yw + "," + string.Format(@"{0}", m_YWGCSJG15[i]);
                co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG15[i]);
                o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG15[i]);
                hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + i]);
                dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + i]);
                xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + i]);
                sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeG15[i]);
                jczt = jczt + "," + string.Format(@"{0}", 1);

            }
            for (int i = 0; i < 30; i++)
            {

                cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15);
                hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJG[i]);
                if (m_TrunGCSJG[i] > 2600 || m_TrunGCSJG[i] < 2400)
                {

                    if (szhuansu.Contains("有"))
                    {
                        m_TrunGCSJG[i] = 2430 + 10 * m_mainform.getRandom(0, 3) + m_mainform.getRandom(0, 9);
                    }
                }
                zs = zs + "," + string.Format(@"{0}", m_TrunGCSJG[i]);
                coclz = coclz + "," + string.Format(@"{0}", m_COGCSJG[i]);
                glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJG[i]);
                yw = yw + "," + string.Format(@"{0}", m_YWGCSJG[i]);
                co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG[i]);
                o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG[i]);
                hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + i]);
                dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + i]);
                xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + i]);
                sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeG[i]);
                jczt = jczt + "," + string.Format(@"{0}", 2);

            }
            for (int i = 0; i < 15; i++)
            {

                cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15 + 30);
                hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJD15[i]);
                zs = zs + "," + string.Format(@"{0}", m_TrunGCSJD15[i]);
                coclz = coclz + "," + string.Format(@"{0}", m_COGCSJD15[i]);
                glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJD15[i]);
                yw = yw + "," + string.Format(@"{0}", m_YWGCSJD15[i]);
                co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD15[i]);
                o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD15[i]);
                hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + 30 + i]);
                dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + 30 + i]);
                xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + 30 + i]);
                sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeD15[i]);
                jczt = jczt + "," + string.Format(@"{0}", 3);

            }

            for (int i = 0; i < 30; i++)
            {

                cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15 + 30 + 15);
                hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJD[i]);
                zs = zs + "," + string.Format(@"{0}", m_TrunGCSJD[i]);
                coclz = coclz + "," + string.Format(@"{0}", m_COGCSJD[i]);
                glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJD[i]);
                yw = yw + "," + string.Format(@"{0}", m_YWGCSJD[i]);
                co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD[i]);
                o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD[i]);
                hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + 45 + i]);
                dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + 45 + i]);
                xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + 45 + i]);
                sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeD[i]);
                jczt = jczt + "," + string.Format(@"{0}", 4);

            }



            ///保存数据库中
            string sql;
            sql = string.Format(@"Select *  from GCSJ_SDS where jylsh='{0}' and  time='{1}'", sjylsh, stime);
            DataTable dt = m_mainform.objbass.objdb.GetTable(sql);
            if (dt.Rows.Count > 0)
            {
                sql = string.Format(@"update GCSJ_SDS  set GCSJ_SDS_hcclz='{0}'
                                                        ,GCSJ_SDS_zs='{1}'
                                                        ,GCSJ_SDS_coclz='{2}'
                                                        ,GCSJ_SDS_glkqxs='{3}'
                                                      ,GCSJ_SDS_yw='{4}'
                                                      ,GCSJ_SDS_co2clz='{5}'
                                                      ,GCSJ_SDS_o2clz='{6}'
                                                      ,GCSJ_SDS_hjwd='{7}'
                                                      ,GCSJ_SDS_dqyl='{8}'
                                                      ,GCSJ_SDS_xdsd='{9}'
                                                      ,GCSJ_SDS_sjxl='{10}'
                                                      ,jczt='{13}'
                                                       where jylsh='{11}' and  time='{12}' ",
                                                        hcclz,
                                                        zs,
                                                        coclz,
                                                        glkqxs,
                                                        yw,
                                                        co2clz,
                                                        o2clz,
                                                        hjwd,
                                                        dqyl,
                                                        xdsd,
                                                        sjxl,
                                                        sjylsh,
                                                        stime,
                                                        jczt);


            }
            else
            {

                sql = string.Format(@"insert into GCSJ_SDS (
                                                jylsh
                                                ,time
                                                ,GCSJ_SDS_hcclz
                                                ,GCSJ_SDS_zs
                                                ,GCSJ_SDS_coclz
                                                ,GCSJ_SDS_glkqxs
                                                ,GCSJ_SDS_yw
                                                ,GCSJ_SDS_co2clz
                                                ,GCSJ_SDS_o2clz
                                                ,GCSJ_SDS_hjwd
                                                ,GCSJ_SDS_dqyl
                                                ,GCSJ_SDS_xdsd
                                                ,GCSJ_SDS_sjxl
                                                ,jczt) values (
                                                '{0}',
                                                '{1}',
                                                '{2}',
                                                '{3}',
                                                '{4}',
                                                '{5}',
                                                '{6}',
                                                '{7}',
                                                '{8}',
                                                 '{9}',
                                                 '{10}',
                                                 '{11}',
                                                 '{12}',
                                                 '{13}')",
                                                sjylsh,
                                                stime,
                                                hcclz,
                                                zs,
                                                coclz,
                                                glkqxs,
                                                yw,
                                                co2clz,
                                                o2clz,
                                                hjwd,
                                                dqyl,
                                                xdsd,
                                                sjxl,
                                                jczt);
            }
            m_mainform.objbass.objdb.InsertDB(sql);
            //


        }

        public void baocunGCSJ_OBD(string sjylsh)
        {
            string sobdgcsj_jqmkd = "";
            string sobdgcsj_fh = "";
            string sobdgcsj_qycgqxh = "";
            string sobdgcsj_glkqxs = "";
            string sobdgcsj_ymkd = "";
            string sobdgcsj_cs = "";
            string sobdgcsj_fdjzs = "";
            string sobdgcsj_jql = "";
            string sobdgcsj_jqyl = "";
            string sobdgcsj_scgl = "";
            string sobdgcsj_zyyl = "";
            string sobdgcsj_hyl = "";
            string sobdgcsj_no = "";
            string sobdgcsj_nsbsl = "";
            string sobdgcsj_pqwd = "";
            string sobdgcsj_klbjqyc = "";
            string sobdgcsj_egrkd = "";
            string sobdgcsj_rypsyl = "";
            string sobdgcsj_sj = "";
            for (int iz = 0; iz < objasmobds.ObdAirPressure.Length; iz++)
            {
                if (!string.IsNullOrWhiteSpace(objasmobds.obdjcsj[iz]))
                {
                    sobdgcsj_jqmkd = sobdgcsj_jqmkd + objasmobds.ObdThrottle[iz] + ",";
                    sobdgcsj_fh = sobdgcsj_fh + objasmobds.ObdCLV[iz] + ",";
                    sobdgcsj_qycgqxh = sobdgcsj_qycgqxh + objasmobds.ObdPreOxygen[iz] + ",";
                    sobdgcsj_glkqxs = sobdgcsj_glkqxs + objasmobds.ObdExcessAirFactor[iz] + ",";
                    sobdgcsj_ymkd = sobdgcsj_ymkd + "" + ",";
                    sobdgcsj_cs = sobdgcsj_cs + objasmobds.ObdSpeed[iz] + ",";
                    sobdgcsj_fdjzs = sobdgcsj_fdjzs + objasmobds.ObdRPM[iz] + ",";
                    sobdgcsj_jql = sobdgcsj_jql + objasmobds.ObdAirInput[iz] + ",";
                    sobdgcsj_jqyl = sobdgcsj_jqyl + objasmobds.ObdAirPressure[iz] + ",";
                    sobdgcsj_scgl = sobdgcsj_scgl + objasmobds.ObdPower[iz] + ",";
                    sobdgcsj_zyyl = sobdgcsj_zyyl + "" + ",";
                    sobdgcsj_hyl = sobdgcsj_hyl + "" + ",";
                    sobdgcsj_no = sobdgcsj_no + "" + ",";
                    sobdgcsj_nsbsl = sobdgcsj_nsbsl + "" + ",";
                    sobdgcsj_pqwd = sobdgcsj_pqwd + "" + ",";
                    sobdgcsj_klbjqyc = sobdgcsj_klbjqyc + "" + ",";
                    sobdgcsj_egrkd = sobdgcsj_egrkd + "" + ",";
                    sobdgcsj_rypsyl = sobdgcsj_rypsyl + "" + ",";
                    sobdgcsj_sj = sobdgcsj_sj + objasmobds.obdjcsj[iz] + ",";

                }
            }
            sobdgcsj_jqmkd = sobdgcsj_jqmkd.TrimEnd(',');
            sobdgcsj_fh = sobdgcsj_fh.TrimEnd(',');
            sobdgcsj_qycgqxh = sobdgcsj_qycgqxh.TrimEnd(',');
            sobdgcsj_glkqxs = sobdgcsj_glkqxs.TrimEnd(',');
            sobdgcsj_ymkd = sobdgcsj_ymkd.TrimEnd(',');
            sobdgcsj_cs = sobdgcsj_cs.TrimEnd(',');
            sobdgcsj_fdjzs = sobdgcsj_fdjzs.TrimEnd(',');
            sobdgcsj_jql = sobdgcsj_jql.TrimEnd(',');
            sobdgcsj_jqyl = sobdgcsj_jqyl.TrimEnd(',');
            sobdgcsj_scgl = sobdgcsj_scgl.TrimEnd(',');
            sobdgcsj_zyyl = sobdgcsj_zyyl.TrimEnd(',');
            sobdgcsj_hyl = sobdgcsj_hyl.TrimEnd(',');
            sobdgcsj_no = sobdgcsj_no.TrimEnd(',');
            sobdgcsj_nsbsl = sobdgcsj_nsbsl.TrimEnd(',');
            sobdgcsj_pqwd = sobdgcsj_pqwd.TrimEnd(',');
            sobdgcsj_klbjqyc = sobdgcsj_klbjqyc.TrimEnd(',');
            sobdgcsj_egrkd = sobdgcsj_egrkd.TrimEnd(',');
            sobdgcsj_rypsyl = sobdgcsj_rypsyl.TrimEnd(',');
            sobdgcsj_sj = sobdgcsj_sj.TrimEnd(',');
            string ssql = string.Format("select * from OBD_ZGCSJ where jylsh='{0}'", sjylsh);
            DataTable dt = m_mainform.objbass.objdb.GetTable(ssql);
            if (dt.Rows.Count > 0)
            {
                ssql = string.Format(@"update OBD_ZGCSJ  set 
sobdgcsj_jqmkd='{0}'
,sobdgcsj_fh='{1}'
,sobdgcsj_qycgqxh='{2}'
,sobdgcsj_glkqxs='{3}'
,sobdgcsj_ymkd='{4}'
,sobdgcsj_cs='{5}'
,sobdgcsj_fdjzs='{6}'
,sobdgcsj_jql='{7}'
,sobdgcsj_jqyl='{8}'
,sobdgcsj_scgl='{9}'
,sobdgcsj_zyyl='{10}'
,sobdgcsj_hyl='{11}'
,sobdgcsj_no='{12}'
,sobdgcsj_nsbsl='{13}'
,sobdgcsj_pqwd='{14}'
,sobdgcsj_klbjqyc='{15}'
,sobdgcsj_egrkd='{16}'
,sobdgcsj_rypsyl='{17}'
,sobdgcsj_sj='{18}'
                                                        where jylsh='{19}'",
sobdgcsj_jqmkd
 , sobdgcsj_fh
 , sobdgcsj_qycgqxh
 , sobdgcsj_glkqxs
 , sobdgcsj_ymkd
 , sobdgcsj_cs
 , sobdgcsj_fdjzs
 , sobdgcsj_jql
 , sobdgcsj_jqyl
 , sobdgcsj_scgl
 , sobdgcsj_zyyl
 , sobdgcsj_hyl
 , sobdgcsj_no
 , sobdgcsj_nsbsl
 , sobdgcsj_pqwd
 , sobdgcsj_klbjqyc
 , sobdgcsj_egrkd
 , sobdgcsj_rypsyl
 , sobdgcsj_sj
 , sjylsh);


            }
            else
            {

                ssql = string.Format(@"insert into OBD_ZGCSJ (
                                               jylsh
                                               ,sobdgcsj_jqmkd 
 ,sobdgcsj_fh 
 ,sobdgcsj_qycgqxh 
 ,sobdgcsj_glkqxs 
 ,sobdgcsj_ymkd 
 ,sobdgcsj_cs 
 ,sobdgcsj_fdjzs 
 ,sobdgcsj_jql 
 ,sobdgcsj_jqyl 
 ,sobdgcsj_scgl 
 ,sobdgcsj_zyyl 
 ,sobdgcsj_hyl 
 ,sobdgcsj_no 
 ,sobdgcsj_nsbsl 
 ,sobdgcsj_pqwd 
 ,sobdgcsj_klbjqyc 
 ,sobdgcsj_egrkd 
 ,sobdgcsj_rypsyl 
 ,sobdgcsj_sj ) values (
                                                '{0}',
                                                '{1}',
                                                '{2}',
                                                '{3}',
                                                '{4}',
                                                '{5}',
                                                '{6}',
                                                '{7}',
                                                '{8}',
                                                '{9}',
                                                '{10}',
                                                '{11}',
                                                '{12}',
                                                '{13}',
                                                '{14}',
                                                '{15}',
                                                '{16}',
                                                '{17}',
                                                '{18}',
                                                '{19}')",
sjylsh
, sobdgcsj_jqmkd
, sobdgcsj_fh
, sobdgcsj_qycgqxh
, sobdgcsj_glkqxs
, sobdgcsj_ymkd
, sobdgcsj_cs
, sobdgcsj_fdjzs
, sobdgcsj_jql
, sobdgcsj_jqyl
, sobdgcsj_scgl
, sobdgcsj_zyyl
, sobdgcsj_hyl
, sobdgcsj_no
, sobdgcsj_nsbsl
, sobdgcsj_pqwd
, sobdgcsj_klbjqyc
, sobdgcsj_egrkd
, sobdgcsj_rypsyl
, sobdgcsj_sj);
            }
            m_mainform.objbass.objdb.InsertDB(ssql);
        }
        public void obdsc()
        {
            gc011 = new 联网通信协议.安车model.GC011();
            string cyds = "";
            string cysx = "";
            string sjxl = "";
            string jqmkd = "";
            string fh = "";
            string qycgqxh = "";
            string glkqxs = "";
            string ymkd = "";
            string cs = "";
            string fdjzs = "";
            string jql = "";
            string jqyl = "";
            string scgl = "";
            string zyyl = "";
            string hyl = "";
            string no = "";
            string nsbsl = "";
            string pqwd = "";
            string klbjqyc = "";
            string egrkd = "";
            string rypsyr = "";
            string jczt = "";

            for (int i = 0; i <= iobd; i++)
            {
                cyds = iobd.ToString();
                cysx = (i + 1).ToString();
                sjxl = sjxl + OBD_sjxl[i] + ",";
                jqmkd = jqmkd + OBD_jqmkd[i] + ",";
                fh = fh + OBD_fh[i] + ",";
                qycgqxh = qycgqxh + OBD_qycgqxh[i] + ",";
                glkqxs = glkqxs + OBD_glkqxs[i] + ",";
                ymkd = ymkd + OBD_ymkd[i] + ",";
                cs = cs + OBD_cs[i] + ",";
                fdjzs = fdjzs + OBD_fdjzs[i] + ",";
                jql = jql + OBD_jql[i] + ",";
                jqyl = jqyl + OBD_jqyl[i] + ",";
                scgl = scgl + OBD_scgl[i] + ",";
                zyyl = zyyl + OBD_zyyl[i] + ",";
                hyl = hyl + OBD_hyl[i] + ",";
                no = no + OBD_no[i] + ",";
                nsbsl = nsbsl + OBD_nsbsl[i] + ",";
                pqwd = pqwd + OBD_pqwd[i] + ",";
                klbjqyc = klbjqyc + OBD_klbjqyc[i] + ",";
                egrkd = egrkd + OBD_egrkd[i] + ",";
                rypsyr = rypsyr + OBD_rypsyl[i] + ",";

            }
            cyds = cyds.Trim(',');
            cysx = cysx.Trim(',');
            sjxl = sjxl.Trim(',');
            jqmkd = jqmkd.Trim(',');
            fh = fh.Trim(',');
            qycgqxh = qycgqxh.Trim(',');
            glkqxs = glkqxs.Trim(',');
            ymkd = ymkd.Trim(',');
            cs = cs.Trim(',');
            fdjzs = fdjzs.Trim(',');
            jql = jql.Trim(',');
            jqyl = jqyl.Trim(',');
            scgl = scgl.Trim(',');
            zyyl = zyyl.Trim(',');
            hyl = hyl.Trim(',');
            no = no.Trim(',');
            nsbsl = nsbsl.Trim(',');
            pqwd = pqwd.Trim(',');
            klbjqyc = klbjqyc.Trim(',');
            egrkd = egrkd.Trim(',');
            rypsyr = rypsyr.Trim(',');
            jczt = jczt.Trim(',');

            gc011.cyds = cyds;
            gc011.cysx = cysx;
            gc011.sjxl = sjxl;
            gc011.jqmkd = jqmkd;
            gc011.fh = fh;
            gc011.qycgqxh = qycgqxh;
            gc011.glkqxs = glkqxs;
            gc011.ymkd = ymkd;
            gc011.cs = cs;
            gc011.fdjzs = fdjzs;
            gc011.jql = jql;
            gc011.jqyl = jqyl;
            gc011.scgl = scgl;
            gc011.zyyl = zyyl;
            gc011.hyl = hyl;
            gc011.no = no;
            gc011.nsbsl = nsbsl;
            gc011.pqwd = pqwd;
            gc011.klbjqyc = klbjqyc;
            gc011.egrkd = egrkd;
            gc011.rypsyl = rypsyr;
            gc011.rypsyr = rypsyr;
            gc011.jczt = jczt;


        }
        public void sdslwzh(bool dsgk)
        {
            联网通信协议.安车model.GC003 gc003 = new 联网通信协议.安车model.GC003();
            联网通信协议.安车model.JC003 jc003 = new 联网通信协议.安车model.JC003();
            string cysx = "";
            string hcclz = "";
            string zs = "";
            string coclz = "";
            string glkqxs = "";
            string yw = "";
            string co2clz = "";
            string o2clz = "";
            string hjwd = "";
            string dqyl = "";
            string xdsd = "";
            string sjxl = "";
            string jczt = "";
            string jcsj = "";
            string gksj = "";

            for (int i = 0; i < 30; i++)
            {
                if (i == 0)
                {
                    cysx = string.Format(@"{0}", i + 1);
                    hcclz = string.Format(@"{0}", m_HCGCSJYR[i]);
                    zs = string.Format(@"{0}", m_TrunGCSJYR[i]);
                    coclz = string.Format(@"{0}", m_COGCSJYR[i]);
                    glkqxs = string.Format(@"{0}", m_LAMDAGCSJYR[i]);
                    sjxl = string.Format(@"{0}", m_ProcessTimeYR[i]);
                    yw = string.Format(@"{0}", m_YWGCSJYR[i].ToString("0.0"));
                    co2clz = string.Format(@"{0}", m_CO2GCSJYR[i]);
                    o2clz = string.Format(@"{0}", m_O2GCSJYR[i]);
                    hjwd = string.Format(@"{0}", m_wendu[i]);
                    dqyl = string.Format(@"{0}", m_daqiya[i]);
                    xdsd = string.Format(@"{0}", m_shidu[i]);
                    jczt = string.Format(@"{0}", 0);
                }
                else
                {
                    cysx = cysx + "," + string.Format(@"{0}", i + 1);
                    hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJYR[i]);
                    zs = zs + "," + string.Format(@"{0}", m_TrunGCSJYR[i]);
                    coclz = coclz + "," + string.Format(@"{0}", m_COGCSJYR[i]);
                    glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJYR[i]);
                    yw = yw + "," + string.Format(@"{0}", m_YWGCSJYR[i].ToString("0.0"));
                    co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJYR[i]);
                    o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJYR[i]);
                    hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[i]);
                    dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[i]);
                    xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[i]);
                    sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeYR[i]);
                    jczt = jczt + "," + string.Format(@"{0}", 0);
                }
            }
            for (int i = 0; i < 15; i++)
            {
                cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30);
                hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJG15[i]);
                zs = zs + "," + string.Format(@"{0}", m_TrunGCSJG15[i]);
                coclz = coclz + "," + string.Format(@"{0}", m_COGCSJG15[i]);
                glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJG15[i]);
                yw = yw + "," + string.Format(@"{0}", m_YWGCSJG15[i].ToString("0.0"));
                co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG15[i]);
                o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG15[i]);
                hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + i]);
                dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + i]);
                xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + i]);

                sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeG15[i]);
                jczt = jczt + "," + string.Format(@"{0}", 1);

            }
            for (int i = 0; i < 30; i++)
            {
                cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15);
                hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJG[i]);
                if (m_TrunGCSJG[i] > 2600 || m_TrunGCSJG[i] < 2400)
                {
                    if (szhuansu.Contains("有"))
                    {
                        if (scllx.Contains("重"))
                        {
                            if (m_TrunGCSJG[i] > 2000 || m_TrunGCSJG[i] < 1600)
                            {
                                m_TrunGCSJG[i] = 1830 + 10 * m_mainform.getRandom(0, 3) + m_mainform.getRandom(0, 9);
                            }
                        }
                        else
                        {
                            if (m_TrunGCSJG[i] > 2600 || m_TrunGCSJG[i] < 2400)
                            {
                                m_TrunGCSJG[i] = 2430 + 10 * m_mainform.getRandom(0, 3) + m_mainform.getRandom(0, 9);
                            }
                        }
                    }
                }
                zs = zs + "," + string.Format(@"{0}", m_TrunGCSJG[i]);
                coclz = coclz + "," + string.Format(@"{0}", m_COGCSJG[i]);
                glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJG[i]);
                yw = yw + "," + string.Format(@"{0}", m_YWGCSJG[i].ToString("0.0"));
                co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG[i]);
                o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG[i]);
                hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + i]);
                dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + i]);
                xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + i]);
                sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeG[i]);
                jczt = jczt + "," + string.Format(@"{0}", 2);
            }
            gksj = "30,15,30";
            jcsj = "75";
            if (dsgk)
            {
                for (int i = 0; i < 15; i++)
                {
                    cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15 + 30);
                    hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJD15[i]);
                    zs = zs + "," + string.Format(@"{0}", m_TrunGCSJD15[i]);
                    coclz = coclz + "," + string.Format(@"{0}", m_COGCSJD15[i]);
                    glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJD15[i]);
                    yw = yw + "," + string.Format(@"{0}", m_YWGCSJD15[i].ToString("0.0"));
                    co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD15[i]);
                    o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD15[i]);
                    hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + 30 + i]);
                    dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + 30 + i]);
                    xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + 30 + i]);
                    sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeD15[i]);
                    jczt = jczt + "," + string.Format(@"{0}", 3);
                }
                for (int i = 0; i < 30; i++)
                {
                    cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15 + 30 + 15);
                    hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJD[i]);
                    zs = zs + "," + string.Format(@"{0}", m_TrunGCSJD[i]);
                    coclz = coclz + "," + string.Format(@"{0}", m_COGCSJD[i]);
                    glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJD[i]);
                    yw = yw + "," + string.Format(@"{0}", m_YWGCSJD[i].ToString("0.0"));
                    co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD[i]);
                    o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD[i]);
                    hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + 45 + i]);
                    dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + 45 + i]);
                    xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + 45 + i]);
                    sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeD[i]);
                    jczt = jczt + "," + string.Format(@"{0}", 4);
                }
                gksj = "30,15,30,15,30";
                jcsj = "120";
            }

            gc003.cyds = jcsj;
            gc003.cysx = cysx;
            gc003.hcclz = hcclz;
            gc003.zs = zs;
            gc003.coclz = coclz;
            gc003.glkqxs = glkqxs;
            gc003.yw = yw;
            gc003.co2clz = co2clz;
            gc003.o2clz = o2clz;
            gc003.hjwd = hjwd;
            gc003.dqyl = dqyl;
            gc003.xdsd = xdsd;
            gc003.sjxl = sjxl;
            gc003.jczt = jczt;
            gc003.gksj = gksj;
            gc003.jcsj = jcsj;//过程数据

            obdsc();

            jc003.wd = fwendu.ToString("0.00");
            jc003.dqy = fdaqiya.ToString("0.00");
            jc003.xdsd = fshidu.ToString("0.00");
            jc003.lambdadown = "0.95";
            jc003.lambdaup = "1.05";
            jc003.lambda = lamda;
            jc003.lambdajudge = ilandapd.ToString();
            jc003.lscolimit = m_mainform.LICOL.ToString("0.0");
            jc003.lscoresult = fCOD.ToString("0.00");
            jc003.lscojudge = (fCOD > m_mainform.LICOL ? 0 : 1).ToString();
            jc003.lshclimit = m_mainform.LIHCL.ToString("0");
            jc003.lshcresult = iHCD.ToString();
            jc003.lshcjudge = (iHCD > m_mainform.LIHCL ? 0 : 1).ToString();
            jc003.dszs = m_TrunGCSJD[0].ToString();
            jc003.ddsjywd = m_YWGCSJD[0].ToString();
            jc003.hscolimit = m_mainform.HICOL.ToString("0.0");
            jc003.hscoresult = fCOG.ToString("0.00");
            jc003.hscojudge = (fCOG > m_mainform.HICOL ? 0 : 1).ToString();
            jc003.hshcresult = iHCG.ToString();
            jc003.hshclimit = m_mainform.HIHCL.ToString("0");
            jc003.hshcjudge = (iHCG > m_mainform.HIHCL ? 0 : 1).ToString();
            jc003.gdszs = m_TrunGCSJG[0].ToString();
            jc003.gdsjywd = m_YWGCSJG[0].ToString();
            jc003.result = (bgood ? 1 : 0).ToString();

            string neirong = m_mainform.objbass.uploadSDS(gc003, gc011, jc003);
            if (neirong.Trim().Length > 0)
            {
                sxianshineirong = neirong;
                xianshixinxi();
                return;
            }
        }
        public void sdslwac(bool dsgk)
        {
            {
                //长沙安车平台
                //过程数据
                string cysx = "";
                string hcclz = "";
                string zs = "";
                string coclz = "";
                string glkqxs = "";
                string yw = "";
                string co2clz = "";
                string o2clz = "";
                string hjwd = "";
                string dqyl = "";
                string xdsd = "";
                string sjxl = "";
                string jczt = "";

                string jcsj = "";
                string gksj = "";

                for (int i = 0; i < 30; i++)
                {
                    if (i == 0)
                    {

                        cysx = string.Format(@"{0}", i + 1);
                        hcclz = string.Format(@"{0}", m_HCGCSJYR[i]);
                        zs = string.Format(@"{0}", m_TrunGCSJYR[i]);
                        coclz = string.Format(@"{0}", m_COGCSJYR[i]);
                        glkqxs = string.Format(@"{0}", m_LAMDAGCSJYR[i]);
                        //yw = string.Format(@"{0}", syouwenYR[i]);
                        //co2clz = string.Format(@"{0}", m_CO2GCSJYR[i]);
                        //o2clz = string.Format(@"{0}", m_O2GCSJYR[i]);
                        //hjwd = string.Format(@"{0}", swenduYR[i]);
                        //dqyl = string.Format(@"{0}", sdaqiyiYR[i]);
                        //xdsd = string.Format(@"{0}", sshiduYR[i]);
                        sjxl = string.Format(@"{0}", m_ProcessTimeYR[i]);
                        yw = string.Format(@"{0}", m_YWGCSJYR[i].ToString("0.0") );
                        co2clz = string.Format(@"{0}", m_CO2GCSJYR[i]);
                        o2clz = string.Format(@"{0}", m_O2GCSJYR[i]);
                        hjwd = string.Format(@"{0}", m_wendu[i]);
                        dqyl = string.Format(@"{0}", m_daqiya[i]);
                        xdsd = string.Format(@"{0}", m_shidu[i]);
                        jczt = string.Format(@"{0}", 0);
                    }
                    else
                    {
                        cysx = cysx + "," + string.Format(@"{0}", i + 1);
                        hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJYR[i]);
                        zs = zs + "," + string.Format(@"{0}", m_TrunGCSJYR[i]);
                        coclz = coclz + "," + string.Format(@"{0}", m_COGCSJYR[i]);
                        glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJYR[i]);
                        //yw = yw + "," + string.Format(@"{0}", syouwenYR[i]);
                        //co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJYR[i]);
                        //o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJYR[i]);
                        //hjwd = hjwd + "," + string.Format(@"{0}", swenduYR[i]);
                        //dqyl = dqyl + "," + string.Format(@"{0}", sdaqiyiYR[i]);
                        //xdsd = xdsd + "," + string.Format(@"{0}", sshiduYR[i]);

                        yw = yw + "," + string.Format(@"{0}", m_YWGCSJYR[i].ToString("0.0"));
                        co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJYR[i]);
                        o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJYR[i]);
                        hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[i]);
                        dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[i]);
                        xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[i]);

                        sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeYR[i]);
                        jczt = jczt + "," + string.Format(@"{0}", 0);
                    }
                }
                for (int i = 0; i < 15; i++)
                {

                    cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30);
                    hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJG15[i]);
                    zs = zs + "," + string.Format(@"{0}", m_TrunGCSJG15[i]);
                    coclz = coclz + "," + string.Format(@"{0}", m_COGCSJG15[i]);
                    glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJG15[i]);
                    //yw = yw + "," + string.Format(@"{0}", syouwenG15[i]);
                    //co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG15[i]);
                    //o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG15[i]);
                    //hjwd = hjwd + "," + string.Format(@"{0}", swenduG15[i]);
                    //dqyl = dqyl + "," + string.Format(@"{0}", sdaqiyiG15[i]);
                    //xdsd = xdsd + "," + string.Format(@"{0}", sshiduG15[i]);

                    yw = yw + "," + string.Format(@"{0}", m_YWGCSJG15[i].ToString("0.0"));
                    co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG15[i]);
                    o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG15[i]);
                    hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + i]);
                    dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + i]);
                    xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + i]);

                    sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeG15[i]);
                    jczt = jczt + "," + string.Format(@"{0}", 1);

                }
                for (int i = 0; i < 30; i++)
                {

                    cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15);
                    hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJG[i]);
                    if (m_TrunGCSJG[i] > 2600 || m_TrunGCSJG[i] < 2400)
                    {

                        if (szhuansu.Contains("有"))
                        {

                            m_TrunGCSJG[i] = 2430 + 10 * m_mainform.getRandom(0, 3) + m_mainform.getRandom(0, 9);


                        }
                    }
                    zs = zs + "," + string.Format(@"{0}", m_TrunGCSJG[i]);
                    coclz = coclz + "," + string.Format(@"{0}", m_COGCSJG[i]);
                    glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJG[i]);
                    //yw = yw + "," + string.Format(@"{0}", syouwenG[i]);
                    //co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG[i]);
                    //o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG[i]);
                    //hjwd = hjwd + "," + string.Format(@"{0}", swenduG[i]);
                    //dqyl = dqyl + "," + string.Format(@"{0}", sdaqiyiG[i]);
                    //xdsd = xdsd + "," + string.Format(@"{0}", sshiduG[i]);

                    yw = yw + "," + string.Format(@"{0}", m_YWGCSJG[i].ToString("0.0"));
                    co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJG[i]);
                    o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJG[i]);
                    hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + i]);
                    dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + i]);
                    xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + i]);

                    sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeG[i]);
                    jczt = jczt + "," + string.Format(@"{0}", 2);

                }
                gksj = "30,15,30";
                jcsj = "75";
                if (dsgk)
                {
                    for (int i = 0; i < 15; i++)
                    {

                        cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15 + 30);
                        hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJD15[i]);
                        zs = zs + "," + string.Format(@"{0}", m_TrunGCSJD15[i]);
                        coclz = coclz + "," + string.Format(@"{0}", m_COGCSJD15[i]);
                        glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJD15[i]);
                        //yw = yw + "," + string.Format(@"{0}", syouwenD15[i]);
                        //co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD15[i]);
                        //o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD15[i]);
                        //hjwd = hjwd + "," + string.Format(@"{0}", swenduD15[i]);
                        //dqyl = dqyl + "," + string.Format(@"{0}", sdaqiyiD15[i]);
                        //xdsd = xdsd + "," + string.Format(@"{0}", sshiduD15[i]);

                        yw = yw + "," + string.Format(@"{0}", m_YWGCSJD15[i].ToString("0.0"));
                        co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD15[i]);
                        o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD15[i]);
                        hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + 30 + i]);
                        dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + 30 + i]);
                        xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + 30 + i]);

                        sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeD15[i]);
                        jczt = jczt + "," + string.Format(@"{0}", 3);

                    }

                    for (int i = 0; i < 30; i++)
                    {

                        cysx = cysx + "," + string.Format(@"{0}", i + 1 + 30 + 15 + 30 + 15);
                        hcclz = hcclz + "," + string.Format(@"{0}", m_HCGCSJD[i]);
                        zs = zs + "," + string.Format(@"{0}", m_TrunGCSJD[i]);
                        coclz = coclz + "," + string.Format(@"{0}", m_COGCSJD[i]);
                        glkqxs = glkqxs + "," + string.Format(@"{0}", m_LAMDAGCSJD[i]);
                        //yw = yw + "," + string.Format(@"{0}", syouwenD[i]);
                        //co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD[i]);
                        //o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD[i]);
                        //hjwd = hjwd + "," + string.Format(@"{0}", swenduD[i]);
                        //dqyl = dqyl + "," + string.Format(@"{0}", sdaqiyiD[i]);
                        //xdsd = xdsd + "," + string.Format(@"{0}", sshiduD[i]);

                        yw = yw + "," + string.Format(@"{0}", m_YWGCSJD[i].ToString("0.0"));
                        co2clz = co2clz + "," + string.Format(@"{0}", m_CO2GCSJD[i]);
                        o2clz = o2clz + "," + string.Format(@"{0}", m_O2GCSJD[i]);
                        hjwd = hjwd + "," + string.Format(@"{0}", m_wendu[30 + 15 + 45 + i]);
                        dqyl = dqyl + "," + string.Format(@"{0}", m_daqiya[30 + 15 + 45 + i]);
                        xdsd = xdsd + "," + string.Format(@"{0}", m_shidu[30 + 15 + 45 + i]);

                        sjxl = sjxl + "," + string.Format(@"{0}", m_ProcessTimeD[i]);
                        jczt = jczt + "," + string.Format(@"{0}", 4);

                    }

                    gksj = "30,15,30,15,30";
                    jcsj = "120";
                }
                string vehispara = "";
                string stoubao = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
                stoubao = stoubao + string.Format(@"<root><head><organ>{0}</organ><jkxlh>{1}</jkxlh><jkid>{2}</jkid></head>",
                                                               m_mainform.organ,
                                                              m_mainform.jkxlh,
                                                               "GC003");
                vehispara = stoubao + string.Format(@"<body><vehispara>
                                <jylsh>{0}</jylsh>
                                <testtimes>{1}</testtimes>
                                <cyds>{2}</cyds>
                                <cysx>{3}</cysx>
                                <hcclz>{4}</hcclz>
			                    <zs>{5}</zs>
			                    <coclz>{6}</coclz>
			                    <glkqxs>{7}</glkqxs>
			                    <yw>{8}</yw>
			                    <co2clz>{9}</co2clz>
			                    <o2clz>{10}</o2clz>
			                    <hjwd>{11}</hjwd>
			                    <dqyl>{12}</dqyl>
			                    <xdsd>{13}</xdsd>
			                    <sjxl>{14}</sjxl>
			                    <jczt>{15}</jczt>
			                    <gksj>{16}</gksj>
			                    <jcsj>{17}</jcsj>
                                 </vehispara>
			                    </body>
                                </root>",
                                       businessId,
                                       m_mainform.testtimes,
                                      jcsj,
                                cysx,
                                hcclz,
                                zs,
                                coclz,
                                glkqxs,
                                yw,
                                co2clz,
                                o2clz,
                                hjwd,
                                dqyl,
                                xdsd,
                                sjxl,
                                jczt,
                                gksj,
                                jcsj);

                obdsc();//发送OBD过程数据
                //过程数据
                WebReferenceCS.VeptsOutAccess m_vesd = new WebReferenceCS.VeptsOutAccess();
                m_vesd.Url = m_mainform.surl;
                string sgc005 = m_vesd.write(vehispara);// m_mainform.decode();
                if (!sgc005.ToUpper().Contains("<CODE>1</CODE>"))
                {
                   
                    m_mainform.baocunRJ("双怠速过程数据", vehispara); //
                    m_mainform.baocunRJ("双怠速过程数据结果", m_mainform.decode(sgc005)); //
                    sxianshineirong = "上传过程数据失败 ";
                    {
                        string sshanghang = string.Format("上传过程数据失败");
                        string sxiahang = string.Format("");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    xianshixinxi();
                    return;
                }


                //检测结果
                //检测结果
                string vehisparajg = "";
                string stoubaojg = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
                stoubaojg = stoubaojg + string.Format(@"<root><head><organ>{0}</organ><jkxlh>{1}</jkxlh><jkid>{2}</jkid></head>",
                                                         m_mainform.organ,
                                                        m_mainform.jkxlh,
                                                         "JC003");
                vehisparajg = stoubaojg + string.Format(@"<body><vehispara>
                                <jylsh>{0}</jylsh>
                                <testtimes>{1}</testtimes>
                                <wd>{2}</wd>
                                <dqy>{3}</dqy>
                                <xdsd>{4}</xdsd>
			                    <lambdadown>{5}</lambdadown>
			                    <lambdaup>{6}</lambdaup>
			                    <lambda>{7}</lambda>
			                    <lambdajudge>{8}</lambdajudge>
			                    <lscolimit>{9}</lscolimit>
			                    <lscoresult>{10}</lscoresult>
			                    <lscojudge>{11}</lscojudge>
			                    <lshclimit>{12}</lshclimit>
			                    <lshcresult>{13}</lshcresult>
			                    <lshcjudge>{14}</lshcjudge>
			                    <dszs>{15}</dszs>
                                <ddsjywd>{16}</ddsjywd>
                                <hscolimit>{17}</hscolimit>
                                <hscoresult>{18}</hscoresult>
                                <hscojudge>{19}</hscojudge>
                                <hshcresult>{20}</hshcresult>
                                <hshclimit>{21}</hshclimit>
                                <hshcjudge>{22}</hshcjudge>
                                <gdszs>{23}</gdszs>
                                <gdsjywd>{24}</gdsjywd>
                                <result>{25}</result>
                                 </vehispara>
			                    </body>
                                </root>",
                                   businessId,
                                   m_mainform.testtimes,
                                    fwendu.ToString("0.00"),
                                    fdaqiya.ToString("0.00"),
                                    fshidu.ToString("0.00"),
                                    0.95,
                                    1.05,
                                     lamda,
                                    ilandapd,
                                    m_mainform.LICOL,
                                    fCOD,
                                    fCOD > m_mainform.LICOL ? 0 : 1,
                                    m_mainform.LIHCL,
                                    iHCD,
                                    iHCD > m_mainform.LIHCL ? 0 : 1,
                                    m_TrunGCSJD[0],
                                    m_YWGCSJD[0],
                                     m_mainform.HICOL,
                                    fCOG,
                                    fCOG > m_mainform.HICOL ? 0 : 1,
                                    iHCG,
                                    m_mainform.HIHCL,
                                    iHCG > m_mainform.HIHCL ? 0 : 1,
                                    m_TrunGCSJG[0],
                                    syouwenG[0],
                                    bgood ? 1 : 0);
                //检测结果
                string sjg005 = m_vesd.write(vehisparajg);
                if (!sjg005.ToUpper().Contains("<CODE>1</CODE>"))
                {
                    m_mainform.baocunRJ("双怠速结果数据", vehisparajg); //
                    m_mainform.baocunRJ("双怠速结果数据结果", m_mainform.decode(sgc005)); //
                    sxianshineirong = "上传数据失败 ";
                    xianshixinxi();
                    {
                        string sshanghang = string.Format("上传数据失败");
                        string sxiahang = string.Format("");
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }

                    return;
                }
                m_mainform.sendjieshuAC(string.Format("{0}", bgood ? 1 : 0));//发送结束
                //
            }
        }

        联网通信协议.安车model.GC011 gc011;
        model.SDS.SDSgcsj objsdsgcsj;
        model.SDS.SDSsj objsdssj;
        public bool sdslwyjj(bool bbz)
        {
            objsdssj.iHCG = iHCG;
            objsdssj.fCOG = fCOG;
            objsdssj.fLAMDAG = fLAMDAG;
            objsdssj.iHCD = iHCD;
            objsdssj.fCOD = fCOD;
            objsdssj.fwendu = fwendu;
            objsdssj.fshidu = fshidu;
            objsdssj.fdaqiya = fdaqiya;
            objsdssj.iHCXZG = iHCXZG > 0 ? iHCXZG : int.Parse(m_mainform.HIHCL.ToString()); ;
            objsdssj.fCOXZG = fCOXZG > 0 ? fCOXZG : m_mainform.HICOL;
            objsdssj.iHCXZD = iHCXZD > 0 ? iHCXZD : int.Parse(m_mainform.LIHCL.ToString());
            objsdssj.fCOXZD = fCOXZD > 0 ? fCOXZD : m_mainform.LICOL;
            objsdssj.bgood = bgood;
            objsdssj.dsfdjzs = dsfdjzs;
            objsdssj.gdsfdjzs = gdsfdjzs;
            objsdssj.jyyw = jyyw;
            objsdssj.fCO2H = fCO2H; ;
            objsdssj.fRevH = fRevH;
            objsdssj.fCO2 = fCO2;
            objsdssj.fRev = fRev;
            objsdssj.lambdajudge = ilandapd.ToString();//新增
            objsdssj.gdsjywd = m_YWGCSJG[0].ToString();//新增
            objsdssj.ddsjywd = m_YWGCSJD[0].ToString();//新增







            objsdsgcsj.m_HCGCSJYR = m_HCGCSJYR;
            objsdsgcsj.m_COGCSJYR = m_COGCSJYR;
            objsdsgcsj.m_O2GCSJYR = m_O2GCSJYR;
            objsdsgcsj.m_CO2GCSJYR = m_CO2GCSJYR;
            objsdsgcsj.m_LAMDAGCSJYR = m_LAMDAGCSJYR;
            objsdsgcsj.m_TrunGCSJYR = m_TrunGCSJYR;
            objsdsgcsj.m_ProcessTimeYR = m_ProcessTimeYR;
            objsdsgcsj.m_YWGCSJYR = m_YWGCSJYR;//预热30秒油温
            objsdsgcsj.syouwenYR = syouwenYR;
            objsdsgcsj.swenduYR = swenduYR;
            objsdsgcsj.sdaqiyiYR = sdaqiyiYR;
            objsdsgcsj.sshiduYR = sshiduYR;
            objsdsgcsj.m_HCGCSJG15 = m_HCGCSJG15;
            objsdsgcsj.m_COGCSJG15 = m_COGCSJG15;
            objsdsgcsj.m_O2GCSJG15 = m_O2GCSJG15;
            objsdsgcsj.m_CO2GCSJG15 = m_CO2GCSJG15;
            objsdsgcsj.m_LAMDAGCSJG15 = m_LAMDAGCSJG15;
            objsdsgcsj.m_TrunGCSJG15 = m_TrunGCSJG15;
            objsdsgcsj.m_ProcessTimeG15 = m_ProcessTimeG15;
            objsdsgcsj.m_YWGCSJG15 = m_YWGCSJG15;//进入高怠速15秒油温
            objsdsgcsj.syouwenG15 = syouwenG15;
            objsdsgcsj.swenduG15 = swenduG15;
            objsdsgcsj.sdaqiyiG15 = sdaqiyiG15;
            objsdsgcsj.sshiduG15 = sshiduG15;
            objsdsgcsj.m_HCGCSJG = m_HCGCSJG;
            objsdsgcsj.m_COGCSJG = m_COGCSJG;
            objsdsgcsj.m_O2GCSJG = m_O2GCSJG;
            objsdsgcsj.m_CO2GCSJG = m_CO2GCSJG;
            objsdsgcsj.m_LAMDAGCSJG = m_LAMDAGCSJG;
            objsdsgcsj.m_TrunGCSJG = m_TrunGCSJG;
            objsdsgcsj.m_ProcessTimeG = m_ProcessTimeG;
            objsdsgcsj.m_YWGCSJG = m_YWGCSJG;//高怠速30秒油温
            objsdsgcsj.syouwenG = syouwenG;
            objsdsgcsj.swenduG = swenduG;
            objsdsgcsj.sdaqiyiG = sdaqiyiG;
            objsdsgcsj.sshiduG = sshiduG;
            objsdsgcsj.m_HCGCSJD15 = m_HCGCSJD15;
            objsdsgcsj.m_COGCSJD15 = m_COGCSJD15;
            objsdsgcsj.m_O2GCSJD15 = m_O2GCSJD15;
            objsdsgcsj.m_CO2GCSJD15 = m_CO2GCSJD15;
            objsdsgcsj.m_LAMDAGCSJD15 = m_LAMDAGCSJD15;
            objsdsgcsj.m_TrunGCSJD15 = m_TrunGCSJD15;
            objsdsgcsj.m_ProcessTimeD15 = m_ProcessTimeD15;
            objsdsgcsj.m_YWGCSJD15 = m_YWGCSJD15;//进入怠速15秒油温
            objsdsgcsj.syouwenD15 = syouwenD15;
            objsdsgcsj.swenduD15 = swenduD15;
            objsdsgcsj.sdaqiyiD15 = sdaqiyiD15;
            objsdsgcsj.sshiduD15 = sshiduD15;

            objsdsgcsj.m_HCGCSJD = m_HCGCSJD;
            objsdsgcsj.m_COGCSJD = m_COGCSJD;
            objsdsgcsj.m_O2GCSJD = m_O2GCSJD;
            objsdsgcsj.m_CO2GCSJD = m_CO2GCSJD;
            objsdsgcsj.m_LAMDAGCSJD = m_LAMDAGCSJD;
            objsdsgcsj.m_TrunGCSJD = m_TrunGCSJD;
            objsdsgcsj.m_ProcessTimeD = m_ProcessTimeD;
            objsdsgcsj.m_YWGCSJD = m_YWGCSJD;//怠速30秒油温
            objsdsgcsj.syouwenD = syouwenD;
            objsdsgcsj.swenduD = swenduD;
            objsdsgcsj.sdaqiyiD = sdaqiyiD;
            objsdsgcsj.sshiduD = sshiduD;

            objsdsgcsj.m_wendu = m_wendu;
            objsdsgcsj.m_shidu = m_shidu;
            objsdsgcsj.m_daqiya = m_daqiya;

            objsdsgcsj.m_NOGCSJYR = m_NOGCSJYR;
            objsdsgcsj.m_NOGCSJG15 = m_NOGCSJG15;
            objsdsgcsj.m_NOGCSJG = m_NOGCSJG;
            objsdsgcsj.m_NOGCSJD15 = m_NOGCSJD15;
            objsdsgcsj.m_NOGCSJD = m_NOGCSJD;
            objsdsgcsj.scllx = scllx;//新增



            //OBD过程数据 
            model.ASM.ASMobdgcsj objasmobd = new model.ASM.ASMobdgcsj();
            objasmobd.ObdAirPressure = OBD_jqyl;
            objasmobd.ObdAirInput = OBD_jql;
            objasmobd.ObdRPM = OBD_fdjzs;
            objasmobd.ObdSpeed = OBD_cs;
            objasmobd.ObdExcessAirFactor = OBD_glkqxs;
            objasmobd.ObdPreOxygen = OBD_qycgqxh;
            objasmobd.ObdCLV = OBD_fh;
            objasmobd.ObdThrottle = OBD_jqmkd;
            objasmobd.Obdsjxl = OBD_sjxl;//新增
            objasmobd.Obdiobd = iobd;//新增
            objasmobd.Obdymkd = OBD_ymkd;//新增
            objasmobd.Obdscgl = OBD_scgl;//新增
            objasmobd.Obdzyyl = OBD_zyyl;//新增
            objasmobd.Obdhyl = OBD_hyl;//新增
            objasmobd.Obdno = OBD_no;//新增
            objasmobd.Obdnsbsl = OBD_nsbsl;//新增
            objasmobd.Obdpqwd = OBD_pqwd;//新增
            objasmobd.Obdklbjqyc = OBD_klbjqyc;//新增
            objasmobd.Obdegrkd = OBD_egrkd;//新增
            objasmobd.Obdrypsyl = OBD_rypsyl;//新增

            string message = m_mainform.objbass.sjuploadSDS(businessId, objsdssj, objsdsgcsj, objasmobd);
            if (!message.Contains("1"))
            {
                sxianshineirong = message;
                xianshixinxi();
                Thread.Sleep(3000);
                return false;
            }
            return true;
        }

        private void timer1_Tick_1(object sender, EventArgs e)
        {

            if (m_mainform.DateDiff(DateTime.Now, dtl) > itlsj * 1000)
            {
                xinxixianshi.Text = string.Format("调零结束请开始检测");
                //skinBut_ksjc.Enabled = true;

                threadzj = new Thread(zijian);
                threadzj.Start();
                timer1.Enabled = false;

            }
        }
        Thread threadzj;
        bool bzijian = true;
        public void zijian()
        {
            m_mainform.objfqy.SendDeviceCmd(26);//
            sxianshineirong = string.Format(@"正在检测环境空气");
            xianshixinxi();//---------
            {
                string sshanghang = string.Format("正在检测环境空气");
                string sxiahang = "";
                m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
            }
            Thread.Sleep(2000);
            DateTime dtime = DateTime.Now;
            while (true)
            {
                if (!bzijian)
                {
                    m_mainform.objfqy.SendDeviceCmd(24);//
                    MethodInvoker ln = new MethodInvoker(setkaishi);
                    this.BeginInvoke(ln);
                    return;
                }
                m_mainform.objfqy.SendDeviceCmd(3);//
                Thread.Sleep(300);
                sxianshineirong = string.Format(@"HC:{0}。CO:{1}。NO:{2}。", m_mainform.objfqy.m_iHc, m_mainform.objfqy.m_fCo.ToString("0.00"), m_mainform.objfqy.m_iNo);
                xianshixinxi();//
                {
                    string sshanghang = string.Format("HC{0}CO{1}NO{2}", m_mainform.objfqy.m_iHc, m_mainform.objfqy.m_fCo.ToString("0.00"), m_mainform.objfqy.m_iNo);
                    string sxiahang = "";
                    m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                }
                //Thread.Sleep(2000);

                if (dtime.AddSeconds(15) < DateTime.Now)
                {
                    break;
                }
            }
            Thread.Sleep(1000);
            m_mainform.objfqy.SendDeviceCmd(24);//
            sxianshineirong = string.Format(@"环境空气检测完成");
            xianshixinxi();//
            {
                string sshanghang = string.Format("环境空气检测完成");
                string sxiahang = "";
                m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
            }
            Thread.Sleep(2000);
            sxianshineirong = string.Format(@"正在检测背景空气");
            xianshixinxi();//
            {
                string sshanghang = string.Format("正在检测背景空气");
                string sxiahang = "";
                m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
            }
            Thread.Sleep(1000);
            m_mainform.objfqy.SendDeviceCmd(25);//dtime = DateTime.Now;
            dtime = DateTime.Now;
            while (true)
            {
                if (!bzijian)
                {
                    m_mainform.objfqy.SendDeviceCmd(24);//
                    MethodInvoker ln = new MethodInvoker(setkaishi);
                    this.BeginInvoke(ln);
                    return;
                }
                m_mainform.objfqy.SendDeviceCmd(3);//
                Thread.Sleep(300);
                sxianshineirong = string.Format(@"HC:{0}。CO:{1}。NO:{2}。", m_mainform.objfqy.m_iHc, m_mainform.objfqy.m_fCo.ToString("0.00"), m_mainform.objfqy.m_iNo);
                xianshixinxi();//
                bool bpd = true;
                if (m_mainform.objfqy.m_iHc > 7 || m_mainform.objfqy.m_fCo >= 0.02 || m_mainform.objfqy.m_iNo >= 5)
                {
                    {
                        string sshanghang = string.Format("HC{0}CO{1}NO{2}", m_mainform.objfqy.m_iHc, m_mainform.objfqy.m_fCo.ToString("0.00"), m_mainform.objfqy.m_iNo);
                        string sxiahang = "背景空气检测不合格";
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                    Thread.Sleep(2000);
                    sxianshineirong = string.Format(@"背景空气检测不合格");
                    xianshixinxi();//
                    bpd = false;
                    Thread.Sleep(2000);
                }
                else
                {
                    {
                        string sshanghang = string.Format("HC{0}CO{1}NO{2}", m_mainform.objfqy.m_iHc, m_mainform.objfqy.m_fCo.ToString("0.00"), m_mainform.objfqy.m_iNo);
                        string sxiahang = "";
                        m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
                    }
                }
                if (bpd && dtime.AddSeconds(14) < DateTime.Now)
                {
                    break;
                }
            }
            //Thread.Sleep(1000);
            //m_mainform.objfqy.SendDeviceCmd(2);//
            Thread.Sleep(1000);
            m_mainform.objfqy.SendDeviceCmd(24);//
            sxianshineirong = string.Format(@"背景空气合格");
            xianshixinxi();//
            {
                string sshanghang = string.Format("背景空气合格");
                string sxiahang = "";
                m_mainform.flowwq.LedWrite(sshanghang, sxiahang, 1);
            }
            Thread.Sleep(2000);
            MethodInvoker lnex = new MethodInvoker(setkaishi);
            this.BeginInvoke(lnex);
        }
        public void setkaishi()
        {
            skinBut_ksjc.Enabled = true;
        }

        public void sendSDSGCSJ(string businessId, string svalue)
        {
            m_mainform.objbass.senddate("HJ11", svalue);
        }

        public void sendSDSstop(string businessId)
        {

            m_mainform.objbass.stop(businessId, bgood ? "1" : "0");
        }
        public void sendSDSJG(string businessId)
        {
            JsonData value = new LitJson.JsonData();
            value["InspectionNum"] = businessId;
            value["StationCode"] = m_mainform.stationCode;
            value["SceneCode"] = m_mainform.lineCode;
            value["VLPN"] = m_mainform.VLPN;
            value["VLPNColor"] = m_mainform.VLPNColor;
            value["VIN"] = m_mainform.VIN;
            value["InspectionOperator"] = m_mainform.InspectionOperator;
            value["InspectionDriver"] = m_mainform.InspectionDriver;
            value["ICheck"] = m_mainform.InspectionOperator;
            value["CheckTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            value["Temperature"] = fwendu;
            value["Pressure"] = fdaqiya;
            value["Humidity"] = fshidu;
            value["IUTID"] = string.Format("{0}{1}{2}", m_mainform.stationCode, m_mainform.lineCode, m_mainform.IUTID);
            value["IUIDATE"] = DateTime.Now.ToString("yyyy-MM-dd");
            value["DetectStartTime"] = timeStart;
            value["DetectEndTime"] = timeEnd;
            value["VDCT"] = bgood ? "1" : "0";
            value["EACR"] = lamda;
            value["EACLU"] = 1.05;
            value["EACLD"] = 0.95;
            value["EACD"] = string.Format("{0}", ilandapd);
            value["LICOR"] = fCOD;
            value["LICOL"] = m_mainform.LICOL;
            value["LICOD"] = fCOD > m_mainform.LICOL ? "0" : "1";
            value["LIHCR"] = iHCD;
            value["LIHCL"] = m_mainform.LIHCL;
            value["LIHCD"] = iHCD > m_mainform.LIHCL ? "0" : "1";
            value["HICOR"] = fCOG;
            value["HICOL"] = m_mainform.HICOL;
            value["HICOD"] = fCOG > m_mainform.HICOL ? "0" : "1";
            value["HIHCR"] = iHCG;
            value["HIHCL"] = m_mainform.HIHCL;
            value["HIHCD"] = iHCG > m_mainform.HIHCL ? "0" : "1";

            string svalue = value.ToJson();
            m_mainform.objbass.senddate("HJ12", svalue);
        }

        private void groupBox7_Enter(object sender, EventArgs e)
        {

        }

        private void TESTSDS_Load(object sender, EventArgs e)
        {
            bobdhg = false;
            控制流程.flowcrtl.iquanjuzhuangtai = 1;
            bydhh = false;
        }
        public bool bfh = false;
        public bool bthread3 = false;
        public bool bthread_time = false;
        public bool bsenddate = false;
        public DateTime sendDate;
        public DateTime sendDate2;
        public DateTime dtgcsj;
        public int igcsjcount_obd = 1;
        model.SDS.SDSgcsjZM objsdszm = new model.SDS.SDSgcsjZM();

        public int igcsjcount = 1;
        model.ASM.ASMobdgcsj objasmobds = new model.ASM.ASMobdgcsj();
        public void Thread3()
        {
            int icountobdds = 0;
            //if (!m_mainform.sconnetname.Contains("安车") && !m_mainform.sconnetname.Contains("智慧"))
            {
                while (true)
                {
                    Thread.Sleep(300);
                    ////
                    //if (bsenddate)
                    //{
                    //    if (m_mainform.DateDiff(DateTime.Now, sendDate) > 900 && !bthread_time)
                    //    {
                    //        bthread_time = true;
                    //        objsdszm.ProcessTime = dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss");
                    //        objsdszm.imslsh = igcsjcount;

                    //        if (m_mainform.objbass.zmgcsjsds(businessId, objsdszm).Contains("1"))
                    //        {
                    //            igcsjcount++;
                    //        }
                    //        if (m_mainform.sfOBD)
                    //        {

                    //            if (m_mainform.objbass.sendOBDGCSJ(businessId, dtgcsj.AddSeconds(igcsjcount_obd).ToString("yyyy-MM-dd HH:mm:ss"), igcsjcount_obd).Contains("1"))
                    //            {
                    //                igcsjcount_obd++;
                    //            }
                    //        }

                    //        sendDate = DateTime.Now;
                    //        bthread_time = false;
                    //    }
                    //}
                    DateTime dtimeobddq = DateTime.Now;
                    if (icountobdds > 0 && dtimeobddq.ToString("yyyy-MM-dd HH:mm:ss") == objasmobds.obdjcsj[icountobdds - 1])
                    {
                        icountobdds--;
                    }
                    if (!m_mainform.getOBD_GCSJ(businessId))//读取OBD过程数据
                    {
                    }
                    objasmobds.ObdAirPressure[icountobdds] = m_mainform.OBD_jqyl.Length < 1 ? "0" : m_mainform.OBD_jqyl;
                    objasmobds.ObdAirInput[icountobdds] = m_mainform.OBD_jql.Length < 1 ? "0" : m_mainform.OBD_jql;
                    objasmobds.ObdRPM[icountobdds] = m_mainform.OBD_fdjzs.Length < 1 ? "0" : m_mainform.OBD_fdjzs;
                    objasmobds.ObdSpeed[icountobdds] = m_mainform.OBD_cs.Length < 1 ? "0" : m_mainform.OBD_cs;
                    objasmobds.ObdExcessAirFactor[icountobdds] = m_mainform.OBD_glkqxs.Length < 1 ? "0" : m_mainform.OBD_glkqxs;
                    objasmobds.ObdPreOxygen[icountobdds] = m_mainform.OBD_qycgqxh.Length < 1 ? "0" : m_mainform.OBD_qycgqxh;
                    objasmobds.ObdCLV[icountobdds] = m_mainform.OBD_fh.Length < 1 ? "0" : m_mainform.OBD_fh;
                    objasmobds.ObdThrottle[icountobdds] = m_mainform.OBD_jqmkd.Length < 1 ? "0" : m_mainform.OBD_jqmkd;
                    objasmobds.ObdPower[icountobdds] = m_mainform.OBD_scgl.Length < 1 ? "0" : m_mainform.OBD_scgl;
                    objasmobds.obdjcsj[icountobdds] = dtimeobddq.ToString("yyyy-MM-dd HH:mm:ss");
                    icountobdds++;
                    if (bthread3)
                    {
                        break;
                    }
                    if (m_mainform.DateDiff(DateTime.Now, sendDate2) > 1500 && m_mainform.sconnetname.Contains("安车") && byw)
                    {
                        sendDate2 = DateTime.Now;
                        //if (m_mainform.sconnetname.Contains("安车") && byw)
                        {

                            fywrg = float.Parse((fywrg + m_mainform.getRandom(1, 5) * 0.05f).ToString("0.00"));

                            if (fywrg > 110)
                            {
                                fywrg = float.Parse((110 + m_mainform.getRandom(1, 5) * 0.05f).ToString("0.00"));
                            }
                        }
                    }
                    Thread.Sleep(500);
                }
                //lzj
            }
           

        }
        public bool setlwgcsj()
        {
            bthread_time = true;
            objsdszm.ProcessTime = dtgcsj.AddSeconds(igcsjcount).ToString("yyyy-MM-dd HH:mm:ss");
            objsdszm.imslsh = igcsjcount;
            bool breturn = false;
            bool bgcsj = false;
            bool bobdgcsj = false;
            if (m_mainform.objbass.zmgcsjsds(businessId, objsdszm).Contains("1"))
            {
                igcsjcount++;
                bgcsj = true;
            }
            if (m_mainform.sfOBD)
            {
                if (m_mainform.objbass.sendOBDGCSJ(businessId, dtgcsj.AddSeconds(igcsjcount_obd).ToString("yyyy-MM-dd HH:mm:ss"), igcsjcount_obd).Contains("1"))
                {
                    igcsjcount_obd++;
                    bobdgcsj = true;
                }
            }
            else
            {
                bobdgcsj = true;
            }
            breturn = bgcsj && bobdgcsj;
            return breturn;
        }
        bool bydhh = false;
        private void 该车为油电混合ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            bydhh = true;
        }

        private void TESTSDS_FormClosing(object sender, FormClosingEventArgs e)
        {

            控制流程.flowcrtl.iquanjuzhuangtai = 0;
        }

        float fywrg = 0;
        bool byw = false;
        private void 油温人工确认ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sql = string.Format(@"
            CREATE TABLE [dbo].[ywrgqr](
	            [id] [int] IDENTITY(1,1) NOT NULL,
	            [jylsh] [varchar](50) NULL,
	            [hphm] [varchar](50) NULL,
	            [yuanyin] [varchar](500) NULL,
	            [czy] [varchar](50) NULL,
	            [yw] [real] NULL,
	            [lrtime] [datetime] NULL
            ) ON [PRIMARY]");
            try
            {
                m_mainform.objbass.objdb.InsertDB(sql);
            }
            catch (Exception ) { }

            尾气流程仪表.youwenrengong f = new 尾气流程仪表.youwenrengong();
            f.slsh = businessId;
            f.shphm = hphm.Text;
            f.scaozuoyuan = m_mainform.InspectionOperator;
            if (f.ShowDialog() == DialogResult.OK)
            {
                byw = true;
                fywrg = f.fyw;
                sql = string.Format("insert into ywrgqr (jylsh,hphm,yuanyin,czy,yw,lrtime) values ('{0}','{1}','{2}','{3}',{4},'{5}')",
                    f.slsh, f.shphm, f.syuanyin, f.scaozuoyuan, f.fyw, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                m_mainform.objbass.objdb.InsertDB(sql);
            }
        }

        bool bobdhg = false;
        private void oBD上传ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bobdhg = true;
        }

        private void form_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F6)
            {
                oBD上传ToolStripMenuItem.Visible = true;
                跳过自检ToolStripMenuItem.Visible = true;
            }

        }

        private void form_KeyUp(object sender, KeyEventArgs e)
        {
            oBD上传ToolStripMenuItem.Visible = false;
            跳过自检ToolStripMenuItem.Visible = false;
        }

        private void contextMenuStrip1_Closed(object sender, ToolStripDropDownClosedEventArgs e)
        {
            oBD上传ToolStripMenuItem.Visible = false;
            跳过自检ToolStripMenuItem.Visible = false;
        }

        private void 跳过自检ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bzijian = false;
        }
    }
}
